For this problem you will try to emulate some basic functions of a Task Manager.
ID: 3911562 • Letter: F
Question
For this problem you will try to emulate some basic functions of a Task Manager. You must support the addition and removal of tasks. Each task will be assigned a priority as a non-negative integer (1,000,000,000=highest, 0=lowest). No two distinctly named tasks will have the same priority. Additionally for a given run you can assume that each task with the same name will have the same priority.
Your Task Manager must support two types of operations. Type 1 is the creation of a new task.
Type 2 is to determine the name of a task with a particular priority.
Input Specification
The first line of input contains a single positive integer n (n ? 10,000,000), which represents the total number of queries and addition deletions combined. Each of the following n lines begins with a single integer; the i-th line’s integer describes the i-th operation type.
- When the beginning integer is 1 the operation is an add task operation. The remaining line will contain a task name followed by the task’s priority.
- Then the beginning integer is 2 the operation is the query operation. The remaining line will contain a single integer representing the desired task name’s priority.
- It is guaranteed that each location will be visited before Stackula’s stack is permanently emptied (after visiting the first location).
- The name of each task will be composed strictly of at most 19 upper and lowercase Latin letters.
Output Specification
For each attempted task addition you will output a single line containing either “ADDED”, which means the task was not already present in the task list and was successfully added, or “REDUNDANT” which means that task was already in the list and therefore not added to the Task Manager.
For each name query operation you will output a single line containing either the associated name with the task or the string “NON-EXISTANT”, which means the task was not in the Task Manager.
Explanations
Case 1
Note in the above pictorial example. We sort the “tasks” in the Binary Search Tree for this problem by their priority (not their name). Every Program added is unique except for the last one (the second “E” for the tenth input operation).
Regarding the program name by priority…
The 11-th operation asks for the name of the task with priority 3. The task with priority 3 is “C”.
The 12-th operation asks for the name of the task with priority 5. The task with priority 5 is “E”.
For the 13-th operation, which asks for the task with priority 10. Our tree should find that there is no task with priority 10. Due to this we print “NON-EXISTANT”.
For the 14-th operation we find that “D” has priority 4.
The 11-th operation asks again for the name of the task with priority 3. Again the task with priority 3 is “C”.
Case 2
There are five unique programs added,
- ProgramOne (operation 1 priority 1)
- BoiledWater (operation 2 priority 2)
- ColdFerret (operation 3 priority 3)
- MoonsShadow (operation 6 priority7)
- ThatOtherProgram (operation 7 priority 6)
For the following 6 name query operations we observe that,
- ColdFerret has priority 3.
- Nothing has priority 5.
- Nothing has priority 10.
- Nothing has priority 4.
- ColdFerrt has priority 3.
- BoiledWater has priority 2.
Case 3
Note that although later in the case ProgramTwo and ProgramThree are added, the first time their priorities are queried they don’t exist yet. For this reason the third and fourth line are
“NON-EXISTANT”. Additionally by the eighth query ProgramThree has not been added, so it also results in “NON-EXISTANT”.
Grading Information
Reading from standard input – 5 points
Writing to standard output – 5 points
Comments, white space usage, and reasonable variable names – 10 points
No output aside from the answer (e.g. no input prompts) – 10 points
Uses strings (char arrays) for the task names – 10 points
Implements Linked Binary Search Tree data structure– 10 points
Your program will be tested on 10 test cases – 5 points each
Five cases will have less than or equal 1000 simultaneous tasks at any given time No points will be awarded to programs that do not compile.
Solutions that don’t try to implement a linked binary search tree will receive a maximum of 50 points
Only cases that finish within the maximum of {5 times the judge solution, 10 seconds} will be graded.
To get Full credit you will likely need to implement a balancing Binary Search Tree. The two methods that will be (or have been) covered in class are Red-Black Trees and AVL Trees.
Explanation / Answer
*Note that this list only contains 8 departments from the south-western corner of France as an example* 8 64 40 32 65 65 64 32 31 31 65 32 82 81 11 9 9 31 11 66 66 9 11 40 33 47 32 64 32 40 47 82 31 65 64 11 31 81 34 66 9 ## Sample Output 64 0 65 1 31 0 9 1 66 0 40 1 32 2 11 2 # Challenge++: If you want to go above and beyond for this challenge, programmatically draw a map of the French departments with actual colors from your unique set (you may randomly pick them or use a [color palette](http://en.wikipedia.org/wiki/Palette_(computing))). Feel free to use the linked SVG file from Wikipedia, since it can be modified through text / XML manipulation. ==================== ##[12/23/13] Challenge #140 [Intermediate] Graph Radius --------------------# [](#IntermediateIcon) *(Intermediate)*: Graph Radius In [graph theory](http://en.wikipedia.org/wiki/Graph_theory), a [graph's radius](http://en.wikipedia.org/wiki/Distance_(graph_theory)) is the minimum eccentricity of any vertex for a given graph. More simply: it is the minimum distance between all possible pairs of vertices in a graph. As an example, the [Petersen graph](http://en.wikipedia.org/wiki/Petersen_graph) has a radius of 2 because any vertex is connected to any other vertex within 2 edges. On the other hand, the [Butterfly graph](http://en.wikipedia.org/wiki/Butterfly_graph) has a radius of 1 since its middle vertex can connect to any other vertex within 1 edge, which is the smallest eccentricity of all vertices in this set. Any other vertex has an eccentricity of 2. # Formal Inputs & Outputs ## Input Description On standard console input you will be given an integer N, followed by an [Adjacency matrix](http://en.wikipedia.org/wiki/Adjacency_matrix). The graph is not directed, so the matrix will always be reflected about the [main diagonal](http://en.wikipedia.org/wiki/Main_diagonal). ## Output Description Print the radius of the graph as an integer. # Sample Inputs & Outputs ## Sample Input 10 0 1 0 0 1 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 1 1 0 0 ## Sample Output 2 ==================== ##[12/23/13] Challenge #146 [Easy] Polygon Perimeter --------------------# [](#EasyIcon) *(Easy)*: Polygon Perimeter [A Polygon](http://en.wikipedia.org/wiki/Polygon) is a geometric two-dimensional figure that has n-sides (line segments) that closes to form a loop. Polygons can be in many different shapes and have many different neat properties, though this challenge is about [Regular Polygons](http://en.wikipedia.org/wiki/Regular_polygon). Our goal is to compute the permitter of an n-sided polygon that has equal-length sides given the [circumradius](http://en.wikipedia.org/wiki/Regular_polygon#Circumradius). This is the distance between the center of the Polygon to any of its vertices; not to be confused with the [apothem](http://en.wikipedia.org/wiki/Apothem)! # Formal Inputs & Outputs ## Input Description Input will consist of one line on standard console input. This line will contain first an integer N, then a floating-point number R. They will be space-delimited. The integer N is for the number of sides of the Polygon, which is between 3 to 100, inclusive. R will be the circumradius, which ranges from 0.01 to 100.0, inclusive. ## Output Description Print the permitter of the given N-sided polygon that has a circumradius of R. Print up to three digits precision. # Sample Inputs & Outputs ## Sample Input 1 5 3.7 ## Sample Output 1 21.748 ## Sample Input 2 100 1.0 ## Sample Output 2 6.282 ==================== ##[12/18/13] Challenge #140 [Intermediate] Adjacency Matrix --------------------# [](#IntermediateIcon) *(Intermediate)*: Adjacency Matrix In [graph theory](http://en.wikipedia.org/wiki/Graph_theory), an [adjacency matrix](http://en.wikipedia.org/wiki/Adjacency_matrix) is a data structure that can represent the edges between nodes for a [graph](http://en.wikipedia.org/wiki/Graph_(mathematics)) in an N x N matrix. The basic idea is that an edge exists between the elements of a row and column if the entry at that point is set to a valid value. This data structure can also represent either a [directed graph](http://en.wikipedia.org/wiki/Directed_graph) or an [undirected graph](http://en.wikipedia.org/wiki/Graph_(mathematics)#Undirected_graph), since you can read the rows as being "source" nodes, and columns as being the "destination" (or vice-versa). Your goal is to write a program that takes in a list of edge-node relationships, and print a directed adjacency matrix for it. Our convention will follow that rows point to columns. Follow the examples for clarification of this convention. [Here's a great online directed graph editor](http://bl.ocks.org/rkirsling/5001347) written in Javascript to help you visualize the challenge. Feel free to post your own helpful links! # Formal Inputs & Outputs ## Input Description On standard console input, you will be first given a line with two space-delimited integers N and M. N is the number of nodes / vertices in the graph, while M is the number of following lines of edge-node data. A line of edge-node data is a space-delimited set of integers, with the special "->" symbol indicating an edge. This symbol shows the edge-relationship between the set of left-sided integers and the right-sided integers. This symbol will only have one element to its left, or one element to its right. These lines of data will also never have duplicate information; you do not have to handle re-definitions of the same edges. An example of data that maps the node 1 to the nodes 2 and 3 is as follows: 1 -> 2 3 Another example where multiple nodes points to the same node: 3 8 -> 2 You can expect input to sometimes create cycles and self-references in the graph. The following is valid: 2 -> 2 3 3 -> 2 Note that there is no order in the given integers; thus "1 -> 2 3" is the same as "1 -> 3 2". ## Output Description Print the N x N adjacency matrix as a series of 0's (no-edge) and 1's (edge). # Sample Inputs & Outputs ## Sample Input 5 5 0 -> 1 1 -> 2 2 -> 4 3 -> 4 0 -> 3 ## Sample Output 01010 00100 00001 00001 00000 ==================== ##[12/16/13] Challenge #145 [Easy] Tree Generation --------------------# [](#EasyIcon) *(Easy)*: Tree Generation Your goal is to draw a tree given the base-width of the tree (the number of characters on the bottom-most row of the triangle section). This "tree" must be drawn through [ASCII art-style graphics](http://en.wikipedia.org/wiki/ASCII_art) on standard console output. It will consist of a 1x3 trunk on the bottom, and a triangle shape on the top. The tree must be centered, with the leaves growing from a base of N-characters, up to a top-layer of 1 character. Each layer reduces by 2 character, so the bottom might be 7, while shrinks to 5, 3, and 1 on top layers. See example output. _[Originally submitted by u/Onkel_Wackelflugel](http://www.reddit.com/r/dailyprogrammer_ideas/comments/1srsde/easy_build_a_christmas_treemenorah_with/)_ # Formal Inputs & Outputs ## Input Description You will be given one line of text on standard-console input: an integer and two characters, all space-delimited. The integer, N, will range inclusively from 3 to 21 and *always* be odd. The next character will be your trunk character. The next character will be your leaves character. Draw the trunk and leaves components with these characters, respectively. ## Output Description Given the three input arguments, draw a centered-tree. It should follow this pattern: (this is the smallest tree possible, with a base of 3) * *** ### Here's a much larger tree, of base 7: * *** ***** ******* ###
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.