Any two nodes which are connected by an edge in a graph are called adjacent node.
|
|
|
- Katherine Davidson
- 9 years ago
- Views:
Transcription
1 . iscuss following. Graph graph G consist of a non empty set V called the set of nodes (points, vertices) of the graph, a set which is the set of edges and a mapping from the set of edges to a set of pairs of elements of V. It is also convenient to write a graph as G=(V,). Notice that definition of graph implies that to every edge of a graph G, we can associate a pair of nodes of the graph. If an edge X Є is thus associated with a pair of nodes (U,V) where U, V Є V then we says that edge x connect U and V.. djacent Nodes ny two nodes which are connected by an edge in a graph are called adjacent node.. irected & Undirected dge In a graph G=(V,) an edge which is directed from one end to another end is called a directed edge, while the edge which has no specific direction is called undirected edge.. irected graph (igraph) graph in which every edge is directed is called directed graph or digraph.. Undirected graph graph in which every edge is undirected is called directed graph or digraph.. Mixed Graph If some of the edges are directed and some are undirected in graph then the graph is called mixed graph. 7. Loop (Sling) n edge of a graph which joins a node to itself is called a loop (sling). 8. Multigraph ny graph which contains some parallel edges is called multigraph. 9. Weighted Graph graph in which weights are assigned to every edge is called weighted graph. 0. Isolated Node In a graph a node which is not adjacent to any other node is called isolated node. Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
2 . Null Graph graph containing only isolated nodes are called null graph. In other words set of edges in null graph is empty.. Path of Graph Let G=(V, ) be a simple digraph such that the terminal node of any edge in the sequence is the initial node of the edge, if any appearing next in the sequence defined as path of the graph.. Length of Path The number of edges appearing in the sequence of the path is called length of path.. egree of vertex The no of edges which have V as their terminal node is call as indegree of node V The no of edges which have V as their initial node is call as outdegree of node V Sum of indegree and outdegree of node V is called its Total egree or egree of vertex.. Simple Path (dge Simple) path in a diagraph in which the edges are distinct is called simple path or edge simple.. lementary Path (Node Simple) path in which all the nodes through which it traverses are distinct is called elementary path. 7. ycle (ircuit) path which originates and ends in the same node is called cycle (circuit). 8. irected directed tree is an acyclic digraph which has one node called its root with in degree 0, while all other nodes have in degree. very directed tree must have at least one node. n isolated node is also a directed tree. 9. Terminal Node (Leaf Node) In a directed tree, any node which has out degree 0 is called terminal node or left node. 0. Level of Node The level of any node is the length of its path from the root.. Ordered In a directed tree an ordering of the nodes at each level is prescribed then such a tree is called ordered tree. Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
3 . orest If we delete the root and its edges connecting the nodes at level, we obtain a set of disjoint tree. set of disjoint tree is a forest.. M ary If in a directed tree the out degree of every node is less than or equal to m then tree is called an m ary tree.. ull or omplete M ary If the out degree of each and every node is exactly equal to m or 0 and their number of nodes at level i is m (i ) then the tree is called a full or complex m ary tree.. Positional M ary If we consider m ary trees in which the m children of any node are assumed to have m distinct positions, if such positions are taken into account, then tree is called positional m ary tree.. Height of the tree The height of a tree is the length of the path from the root to the deepest node in the tree. 7. inary tree If in a directed tree the out degree of every node is less than or equal to then tree is called binary tree. 8. Strictly binary tree strictly binary tree (sometimes proper binary tree or tree or full binary tree) is a tree in which every node other than the leaves has two children. 9. omplete binary tree If the out degree of each and every node is exactly equal to or 0 and their number of nodes at level i is (i ) then the tree is called a full or complete binary tree. 0. Sibling Siblings are nodes that share the same parent node.. inary search tree binary search tree is a binary tree in which each node possessed a key that satisfy the following conditions. ll key (if any) in the left sub tree of the root precedes the key in the root.. The key in the root precedes all key (if any) in the right sub tree.. The left and right sub tree sub trees of the root are again search trees. Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
4 . Height alanced inary tree (VL ) tree is called VL (height balance binary tree), if each node possesses one of the following properties. node is called left heavy if the longest path in its left sub tree is one longer then the longest path of its right sub tree.. node is called right heavy if the longest path in the right sub tree is one longer than path in its left sub tree.. node is called balanced, if the longest path in both the right and left sub tree are equal.. xplain the Preorder, Inorder and Postorder traversal techniques of the binary tree with suitable example. The most common operations performed on tree structure is that of traversal. This is a procedure by which each node in the tree is processed exactly once in a systematic manner. There are three ways of traversing a binary tree. Preorder Preorder traversal of a binary tree is defined as follow o Process the root node o Traverse the left subtree in preorder o Traverse the right subtree in preorder If particular subtree is empty (i.e., node has no left or right descendant) the traversal is performed by doing nothing, In other words, a null subtree is considered to be fully traversed when it is encountered. Preorder traversal : G Inorder traversal : G Postorder traversal : G G onverse Preorder traversal : onverse Inorder traversal : G G ig.. onverse Postorder traversal : G The preorder traversal of a tree (ig..) is given by G Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
5 Inorder The Inorder traversal of a binary tree is given by following steps, o Traverse the left subtree in Inorder o Process the root node o Traverse the right subtree in Inorder The Inorder traversal of a tree (ig..) is given by G Postorder The postorder traversal is given by o Traverse the left subtree in postorder o Traverse the right subtree in postorder o Process the root node The Postorder traversal of a tree (ig..) is given by G onverse If we interchange left and right words in the preceding definitions, we obtain three new traversal orders which are called o onverse Preorder ( G ) o onverse Inorder (G ) o onverse Postorder (G ). Write the algorithm of Preorder, Inorder and Postorder traversal techniques of the binary tree. Procedure : RPRORR(T) Given a binary tree whose root node address is given by pointer variable T and whose node structure is same as described below. This procedure traverse the tree in preorder, in a recursive manner. Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
6 LPTR T RPTR. [heck for empty ] If T = NULL then write ( mpty ) return else write (T(T)). [Process the Left Subtree] If LPTR (T) NULL then RPRORR (LPTR (T)). [Process the Right Subtree] If RPTR (T) NULL then RPRORR (RPTR (T)). [inished] return Procedure : RINORR(T) Given a binary tree whose root node address is given by pointer variable T and whose node structure is same as described below. This procedure traverse the tree in inorder, in a recursive manner.. [heck for empty ] If T = NULL then write ( mpty ) return. [Process the Left Subtree] If LPTR (T) NULL then RINORR (LPTR (T)). [Process the root node] write (T(T)). [Process the Right Subtree] If RPTR (T) NULL then RINORR (RPTR (T)). [inished] return Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
7 Procedure : RPOSTORR(T) Given a binary tree whose root node address is given by pointer variable T and whose node structure is same as described below. This procedure traverse the tree in postorder, in a recursive manner.. [heck for empty ] If T = NULL then write ( mpty ) return. [Process the Left Subtree] If LPTR (T) NULL then RPOSTORR (LPTR (T)). [Process the Right Subtree] If RPTR (T) NULL then RPOSTORR (RPTR (T)). [Process the root node] write (T(T)). [inished] return. Give traversal order of following tree into Inorder, Preorder and Postorder. Inorder: Preorder: Post order: 7 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
8 . onstruct a tree for the given Inorder and Postorder traversals Inorder : G H I Postorder : G H I G H I G H I G H I 8 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
9 Postorder : H G I Inorder : G H I G H I G H I G H I G I H 9 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
10 . onstruct a tree for the given Inorder and Preorder traversals Preorder : G Q K P R H Inorder : Q K G P H R G Q K P H R G P Q K R H G P Q K R H G P Q R K H 0 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
11 7. reate a binary search tree for the following data : 0,,7,,0,0,80,90,, onstruct binary search tree for the following data and find its Inorder, Preorder and Postorder traversal 0,,,,,,,,78,, 0 78 Preorder : 0,,,,,,,,,, 78 Inorder :,,, 0,,,,,,, 78 Postorder :,,,,, 78,,,,, 0 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
12 9. Write a short note on threaded binary tree The wasted NULL links in the binary tree storage representation can be replaced by threads. binary tree is threaded according to particular traversal order. e.g.: Threads for the inorder traversals of tree are pointers to its higher nodes, for this traversal order. o If left link of node P is null, then this link is replaced by the address of its predecessor. o If right link of node P is null, then it is replaced by the address of its successor ecause the left or right link of a node can denote either structural link or a thread, we must somehow be able to distinguish them. Method : Represent thread a ve address. Method : To have a separate oolean flag for each of leaf and right pointers, node structure for this is given below, LPTR LTHR ata RTHR RPTR lternate node for threaded binary tree. LTHR = true = enotes leaf thread link LTHR = false = enotes leaf structural link RTHR = true = enotes right threaded link RTHR = false = enotes right structural link Head node is simply another node which serves as the predecessor and successor of first and last tree nodes. is attached to the left branch of the head node Head dvantages Inorder traversal I faster than unthreaded version as tack is not required. ffectively determines the predecessor and successor for inorder traversal, for unthreaded tree this task is more difficult. stack is required to provide upward pointing information in tree which threading provides. It is possible to generate successor or predecessor of any node without having over head of stock with the help of threading. isadvantages Threaded trees are unable to share common subtrees If ve addressing is not permitted in programming language, two additional fields are required. Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
13 Insertion into and deletion from threaded binary tree are more time consuming because both thread and structural link must be maintained. inary Inorder Traversal G G ully In threaded binary tree of given binary tree H G Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
14 0. raw a right in threaded binary tree for the given tree Right In threaded binary tree of given binary tree H H G Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
15 . What is the meaning of height balanced tree? How rebalancing is done in height balanced tree. tree is called VL (height balance binary tree), if each node possesses one of the following properties. node is called left heavy if the longest path in its left sub tree is one longer then the longest path of its right sub tree.. node is called right heavy if the longest path in the right sub tree is one longer than path in its left sub tree.. node is called balanced, if the longest path in both the right and left sub tree are equal. If tree becomes unbalanced by inserting any node, then based on position of insertion, we need to rotate the unbalanced node. Rotation is the process to make tree balanced ) Insertion into Left sub tree of nodes Left child Single Right Rotation ) Insertion into Right sub tree of node s Left child Left Right Rotation ) Insertion into Left sub tree of node s Right child Right Left Rotation ) Insertion into Right sub tree of node s Right child Single Left Rotation ) Insertion into Left sub tree of nodes Left child Single Right Rotation If node becomes unbalanced after insertion of new node at Left sub tree of nodes Left child, then we need to perform Single Right Rotation for unbalanced node. Right Rotation a. etach leaf child s right sub tree b. onsider leaf child to be the new parent c. ttach old parent onto right of new parent d. ttach old leaf child s old right sub tree as leaf sub tree of new right child ritical Node J K K Z Right Rotation X J X Y N Y Z N Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
16 ritical Node 7 7 Steps of Right Rotation ) Insertion into Right sub tree of node s Left child Left Right Rotation If node becomes unbalanced after insertion of new node at Right sub tree of node s Left child, then we need to perform Left Right Rotation for unbalanced node. Leaf rotation of leaf child followed by right rotation of parent J J Y X K Y Z Left Rotation of K K Y n Z Right Rotation of J K X n Z J n X ) Insertion into Left sub tree of node s Right child Right Left Rotation If node becomes unbalanced after insertion of new node at Left sub tree of node s Right child, then we need to perform Right Left Rotation for unbalanced node. Single right rotation of right child followed by left rotation of parent Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
17 X Unbalanced node X Y T Y Z T Right Rotation of Z T T Y Z Left Rotation of X X Z T T T T T T T T ) Insertion into Right sub tree of node s Right child Single Left Rotation If node becomes unbalanced after insertion of new node at Right sub tree of nodes Right child, then we need to perform Single Left Rotation for unbalanced node. Left Rotation a. etach right child s leaf sub tree b. onsider right child to be new parent c. ttach old parent onto left of new parent d. ttach old right child s old left sub tree as right sub tree of new left child X Unbalanced node Y T Y Leaf Rotation of X X T T T T T n n xample 0 Unbalanced node Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
18 . onstruct VL Search tree by inserting following elements in order of their occurrence,,,,, Insert Insert : Insert : Right Insert : Rotate Insert : Righ Insert : Rotate Right Rotate ssignment: efine height of the binary tree. efine height balanced tree with its advantages. onstruct a height balanced binary tree (VL tree) for the following data,0,,,88,0,,,, onstruct the VL search tree by inserting the following elements in the order of their occurrence.,,,,, 0, 98, 8 8 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
19 . What are the advantages of Multiway search tree in disc access? onstruct tree of order for the following data,7,,,,,0,,,0,,,,,8,9,, Insert: Insert: Insert: 7 Insert: Insert:,,, 7,,, 7,,, 7, Overflow, 7, Insert: Insert: Insert:,, 7,,, 7, 0,,, 7, 0,, Insert: 9 0 Insert: 0,,,, 7, 0,,, Overflow,, 7, 0,,, 7, 0,, 0 Insert: Insert:,,, 7, 0,,, 0,,,,, 7, 0,,, 0, Overflow,, 7, 0, 0,, 9 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
20 Insert:,,,,,,, 7, 0, 0,,, 7, 0, 0, Overflow Insert: 8, 9,,, 7, 0,, 8, 9, 0, Insert:,, 7, 0,, 8, 9, 0,, Overflow,, 0,, 7, 0,, 8, 9, ssignment: onstruct mutiway search tree for the following data of order for 00, 0, 0,, 0, 00, 70,, 7, 0, 0,, 0,, 80, 90, 00, 0 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
21 . What is tree? tree is a type of data structure, where every node with children has either two children or three children. very non leaf is a node or a node. ll leaves are at the same level (the bottom level) ll data are kept in sorted order very non leaf node will contain or fields. What is graph? How it can be represented using adjacency matrix, what is path matrix? How path matrix can be found out using adjacency matrix. Graph graph G consist of a non empty set V called the set of nodes (points, vertices) of the graph, a set which is the set of edges and a mapping from the set of edges to a set of pairs of elements of V. It is also convenient to write a graph as G=(V,). Notice that definition of graph implies that to every edge of a graph G, we can associate a pair of nodes of the graph. If an edge X Є is thus associated with a pair of nodes (U,V) where U, V Є V then we says that edge x connect U and V. djacency matrix Let G = (V, ) be a simple diagraph in which V = {v, v,., v n } and the nodes are assumed to be ordered from v to v n. n n x n matrix whose elements are a ij are given by, a ij = 0 is called adjacency matrix of the graph G. ny element of the adjacency matrix is either 0 or. or a given graph G =m (V, ), an adjacency matrix depends upon the ordering of the elements of V. or different ordering of the elements of V we get different adjacency matrices. V V V V V V V V V 0 0 V V 0 V digraph and its adjacency matrix Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
22 We can extend the idea of matrix representation to multigraph sand weighted graphs. In the case of multigraph or weighted graph we write a ji = w, where a ij denotes either the multiplicity it the weight of the edge. Path matrix n entry of in the ith row and jth column of shows the existence of an edge (v i, v j ), that is a path of length from v i to v j. Let denote the elements of by a () ij. Then Therefore a () ij is equal to the number of different paths of exactly length from v i to v j. Similarly element in i th row and j th column of gives number of paths of exactly length from v i to v j. = = = ifferent path matrices. Which are the basic traversing techniques of the Graph? Write the algorithm of them. Most graph problems involve traversal of a graph. Traversal of a graph means visit each node exactly once. Two commonly used graphs traversal techniques are. epth irst Search (S). readth irst Search (S) epth irst Search (S) It is like preorder traversal of tree. Traversal can start from any vertex vi Vi is visited and then all vertices adjacent to vi are traversed recursively using S Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
23 S (G, ) is given by 7 a) Visit () b) S (G, ) S (G, ) S (G, ) S (G, ) 8 S traversal of given graph is:,,,, 8, 7,, Graph G Since graph can have cycles, we must avoid re visiting a node. To do this when we visit a vertex V, we marks it visited as visited should not be selected for traversal. Procedure : S (vertecx V) This procedure traverse the graph G in S manner. V is a starting vertex to be explored. S is a Stack, visited[] is an array which tells you whether particular vertex is visited or not. W is a adjacent node of vertex V. PUSH and POP are functions to insert and remove from stack respectively.. [Initialize TOP and Visited] visited[] 0 TOP 0. [Push vertex into stack] PUSH (V). [Repeat while stack is not empty] Repeat step while stack is not empty v POP() if visited[v] is 0 then visited [v] for all W adjacent to v if visited [v] is 0 then PUSH (W) end for end if Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
24 readth irst Search (S) This methods starts from vertex v 0 V 0 is marked as visited. ll vertices adjacent to v 0 are visited next Let vertices adjacent to v 0 are v, v, v, v v, v, v and v are marked visited. ll unvisited vertices adjacent to v, v, v, v are visited next. The method continuous until all vertices are visited The algorithm for S has to maintain a list of vertices which have been visited but not explored for adjacent vertices. The vertices which have been visited but not explored for adjacent vertices can be stored in queue. Initially the queue contains the starting vertex. In every iteration, a vertex is removed from the queue and its adjacent vertices which are not visited as yet are added to the queue. The algorithm terminates when the queue becomes empty. Graph G S traversal of given graph is:,,,, Procedure : S (Vertex V) This procedure traverse the graph G in S manner. V is a starting vertex to be explored. Q is a queue, visited[] is an array which tells you whether particular vertex is visited or not. W is a adjacent node of vertex V.. Initialize Q. [Marks visited of V as ] visited [v]. [dd vertex v to Q] InsertQueue(V). [Repeat while Q is not empty] Repeat while Q is not empty v RemoveromQueue() or all vertices W adjacent to v if visited[w] is 0 then visited[w] InsertQueue(w) Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
25 7. What is spanning tree? Spanning tree of a graph is an undirected tree consisting of only those edges necessary to connect all the nodes in the original graph spanning tree has the properties that o or any pair of nodes there exists only one path between them o Insertion of any edge to a spanning tree forms a unique cycle The particular Spanning for a graph depends on the criteria used to generate it. If S search is use, those edges traversed by the algorithm forms the edges of tree, referred to as epth irst Spanning. If S Search is used, the spanning tree is formed from those edges traversed during the search, producing readth irst Search Spanning tree. V0 V V V V V V V7 V0 V0 V V V V V V V V V V V V V7 S Spanning V7 S Spanning Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
26 8. onsider the graph shown in ig ind depth first and breadth first traversals of this graph starting at S : S : Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
27 9. efine spanning tree and minimum spanning tree. ind the minimum spanning tree of the graph shown in ig. 7 Using Prim s lgorithm: Let X be the set of nodes explored, initially X = { } Step : Taking minimum weight edge of all djacent edges of X = { } X = {, } Step : Taking minimum weight edge of all djacent edges of X = {, } X = {,, } 7 Step : Taking minimum weight edge of all djacent edges of X = {,, } Step : Taking minimum weight edge of all djacent edges of X = {,,, } X = {,,, } X = {,,,, } ll nodes of graph are there with set X, so we obtained minimum spanning tree of cost: = 0 7 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
28 7 Using Kruskal s lgorithm Step : Taking min edge (,) Step : Taking next min edge (,) Step : Taking next min edge (,) Step : Taking next min edge (,) Step : Taking next min edge (,) it forms cycle so do not consider Step : Taking next min edge (,) it forms cycle so do not consider Step 7: Taking next min edge (,) it forms cycle so do not consider Step 8: Taking next min edge (,) it forms cycle so do not consider Step 9: Taking next min edge (,) it forms cycle so do not consider ll edges of graph has been visited, so we obtained minimum spanning tree of cost: = 0 0. Give example and applications of directed and undirected graphs. ind the adjacency matrix for the graph shown in ig. djacency matrix for the given graph Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
29 pplications of graph: lectronic ircuits o Printed ircuit oard o Integrated ircuit Transportation networks o Highway networks Modeling a road network with vertexes as towns and edge costs as distances. o Water Supply networks Modeling a water supply network. cost might relate to current or a function of capacity and length. s water flows in only direction, from higher to lower pressure connections or downhill, such a network is inherently an acyclic directed graph. o light network Minimizing the cost and time taken for air travel when direct flights don't exist between starting and ending airports. omputer networks o Local rea Network o Internet ynamically modeling the status of a set of routes by which traffic might be directed over the Internet. o Web Using a directed graph to map the links between pages within a website and to analyze ease of navigation between different parts of the site. atabases o ntity Relationship iagram 9 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure
30 0 Prof. Pradyumansinh Jadeja (987988) 070 ata & ile Structure. pply ijkstra s algorithm to find shortest path between vertex and vertex for the graph shown in ig. 7 7 Step : Traverse all adjacent node of 0 7 Step : Traverse all adjacent node of 0 7 Step : Traverse all adjacent node of 0 7 Step : Traverse all adjacent node of Step : Traverse all adjacent node of 0 7 Shortest path from node to is : as shown in step Length of path is 7
Data Structure [Question Bank]
Unit I (Analysis of Algorithms) 1. What are algorithms and how they are useful? 2. Describe the factor on best algorithms depends on? 3. Differentiate: Correct & Incorrect Algorithms? 4. Write short note:
Social Media Mining. Graph Essentials
Graph Essentials Graph Basics Measures Graph and Essentials Metrics 2 2 Nodes and Edges A network is a graph nodes, actors, or vertices (plural of vertex) Connections, edges or ties Edge Node Measures
IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*
IE 680 Special Topics in Production Systems: Networks, Routing and Logistics* Rakesh Nagi Department of Industrial Engineering University at Buffalo (SUNY) *Lecture notes from Network Flows by Ahuja, Magnanti
root node level: internal node edge leaf node CS@VT Data Structures & Algorithms 2000-2009 McQuain
inary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from each
1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++
Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The
Ordered Lists and Binary Trees
Data Structures and Algorithms Ordered Lists and Binary Trees Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/62 6-0:
Atmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : 572365, 576681 1
Data Structure By Ajay Raiyani Yogidham, Kalawad Road, Rajkot. Ph : 572365, 576681 1 Linked List 4 Singly Linked List...4 Doubly Linked List...7 Explain Doubly Linked list: -...7 Circular Singly Linked
Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit
Data Structures Page 1 of 24 A.1. Arrays (Vectors) n-element vector start address + ielementsize 0 +1 +2 +3 +4... +n-1 start address continuous memory block static, if size is known at compile time dynamic,
Binary Search Trees CMPSC 122
Binary Search Trees CMPSC 122 Note: This notes packet has significant overlap with the first set of trees notes I do in CMPSC 360, but goes into much greater depth on turning BSTs into pseudocode than
TREE BASIC TERMINOLOGIES
TREE Trees are very flexible, versatile and powerful non-liner data structure that can be used to represent data items possessing hierarchical relationship between the grand father and his children and
Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C
Tutorial#1 Q 1:- Explain the terms data, elementary item, entity, primary key, domain, attribute and information? Also give examples in support of your answer? Q 2:- What is a Data Type? Differentiate
DATA STRUCTURES USING C
DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give
GRAPH THEORY LECTURE 4: TREES
GRAPH THEORY LECTURE 4: TREES Abstract. 3.1 presents some standard characterizations and properties of trees. 3.2 presents several different types of trees. 3.7 develops a counting method based on a bijection
Data Structures and Algorithms
Data Structures and Algorithms CS245-2016S-06 Binary Search Trees David Galles Department of Computer Science University of San Francisco 06-0: Ordered List ADT Operations: Insert an element in the list
Binary Search Trees (BST)
Binary Search Trees (BST) 1. Hierarchical data structure with a single reference to node 2. Each node has at most two child nodes (a left and a right child) 3. Nodes are organized by the Binary Search
2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]
Code No: R05220502 Set No. 1 1. (a) Describe the performance analysis in detail. (b) Show that f 1 (n)+f 2 (n) = 0(max(g 1 (n), g 2 (n)) where f 1 (n) = 0(g 1 (n)) and f 2 (n) = 0(g 2 (n)). [8+8] 2. (a)
Exam study sheet for CS2711. List of topics
Exam study sheet for CS2711 Here is the list of topics you need to know for the final exam. For each data structure listed below, make sure you can do the following: 1. Give an example of this data structure
CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.
Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure
Algorithms and Data Structures
Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2
5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.
1. The advantage of.. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists. [A] Lists [B] Linked Lists [A] Trees [A] Queues 2. The
Analysis of Algorithms I: Binary Search Trees
Analysis of Algorithms I: Binary Search Trees Xi Chen Columbia University Hash table: A data structure that maintains a subset of keys from a universe set U = {0, 1,..., p 1} and supports all three dictionary
Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R
Binary Search Trees A Generic Tree Nodes in a binary search tree ( B-S-T) are of the form P parent Key A Satellite data L R B C D E F G H I J The B-S-T has a root node which is the only node whose parent
Data Structure with C
Subject: Data Structure with C Topic : Tree Tree A tree is a set of nodes that either:is empty or has a designated node, called the root, from which hierarchically descend zero or more subtrees, which
Binary Trees and Huffman Encoding Binary Search Trees
Binary Trees and Huffman Encoding Binary Search Trees Computer Science E119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Motivation: Maintaining a Sorted Collection of Data A data dictionary
PES Institute of Technology-BSC QUESTION BANK
PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions
International Journal of Software and Web Sciences (IJSWS) www.iasir.net
International Association of Scientific Innovation and Research (IASIR) (An Association Unifying the Sciences, Engineering, and Applied Research) ISSN (Print): 2279-0063 ISSN (Online): 2279-0071 International
Symbol Tables. Introduction
Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The
B-Trees. Algorithms and data structures for external memory as opposed to the main memory B-Trees. B -trees
B-Trees Algorithms and data structures for external memory as opposed to the main memory B-Trees Previous Lectures Height balanced binary search trees: AVL trees, red-black trees. Multiway search trees:
Data Structures. Level 6 C30151. www.fetac.ie. Module Descriptor
The Further Education and Training Awards Council (FETAC) was set up as a statutory body on 11 June 2001 by the Minister for Education and Science. Under the Qualifications (Education & Training) Act,
Data Structures and Algorithms Written Examination
Data Structures and Algorithms Written Examination 22 February 2013 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where
DATA ANALYSIS II. Matrix Algorithms
DATA ANALYSIS II Matrix Algorithms Similarity Matrix Given a dataset D = {x i }, i=1,..,n consisting of n points in R d, let A denote the n n symmetric similarity matrix between the points, given as where
Previous Lectures. B-Trees. External storage. Two types of memory. B-trees. Main principles
B-Trees Algorithms and data structures for external memory as opposed to the main memory B-Trees Previous Lectures Height balanced binary search trees: AVL trees, red-black trees. Multiway search trees:
Learning Outcomes. COMP202 Complexity of Algorithms. Binary Search Trees and Other Search Trees
Learning Outcomes COMP202 Complexity of Algorithms Binary Search Trees and Other Search Trees [See relevant sections in chapters 2 and 3 in Goodrich and Tamassia.] At the conclusion of this set of lecture
MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push) -----------------------------------------
=============================================================================================================================== DATA STRUCTURE PSEUDO-CODE EXAMPLES (c) Mubashir N. Mir - www.mubashirnabi.com
Converting a Number from Decimal to Binary
Converting a Number from Decimal to Binary Convert nonnegative integer in decimal format (base 10) into equivalent binary number (base 2) Rightmost bit of x Remainder of x after division by two Recursive
Data Structures UNIT III. Model Question Answer
Data Structures UNIT III Model Question Answer Q.1. Define Stack? What are the different primitive operations on Stack? Ans: Stack: A stack is a linear structure in which items may be added or removed
INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY
INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY A PATH FOR HORIZING YOUR INNOVATIVE WORK A REVIEW ON THE USAGE OF OLD AND NEW DATA STRUCTURE ARRAYS, LINKED LIST, STACK,
A binary search tree is a binary tree with a special property called the BST-property, which is given as follows:
Chapter 12: Binary Search Trees A binary search tree is a binary tree with a special property called the BST-property, which is given as follows: For all nodes x and y, if y belongs to the left subtree
Questions 1 through 25 are worth 2 points each. Choose one best answer for each.
Questions 1 through 25 are worth 2 points each. Choose one best answer for each. 1. For the singly linked list implementation of the queue, where are the enqueues and dequeues performed? c a. Enqueue in
Graph Theory and Topology Design
raph Theory and Topology esign avid Tipper ssociate Professor raduate Telecommunications and Networking Program University of Pittsburgh [email protected] Slides http://www.sis.pitt.edu/~dtipper/0.html
Parallelization: Binary Tree Traversal
By Aaron Weeden and Patrick Royal Shodor Education Foundation, Inc. August 2012 Introduction: According to Moore s law, the number of transistors on a computer chip doubles roughly every two years. First
10CS35: Data Structures Using C
CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a
Chapter 14 The Binary Search Tree
Chapter 14 The Binary Search Tree In Chapter 5 we discussed the binary search algorithm, which depends on a sorted vector. Although the binary search, being in O(lg(n)), is very efficient, inserting a
CMPSCI611: Approximating MAX-CUT Lecture 20
CMPSCI611: Approximating MAX-CUT Lecture 20 For the next two lectures we ll be seeing examples of approximation algorithms for interesting NP-hard problems. Today we consider MAX-CUT, which we proved to
1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.
1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. base address 2. The memory address of fifth element of an array can be calculated
Warshall s Algorithm: Transitive Closure
CS 0 Theory of Algorithms / CS 68 Algorithms in Bioinformaticsi Dynamic Programming Part II. Warshall s Algorithm: Transitive Closure Computes the transitive closure of a relation (Alternatively: all paths
Cpt S 223. School of EECS, WSU
The Shortest Path Problem 1 Shortest-Path Algorithms Find the shortest path from point A to point B Shortest in time, distance, cost, Numerous applications Map navigation Flight itineraries Circuit wiring
V. Adamchik 1. Graph Theory. Victor Adamchik. Fall of 2005
V. Adamchik 1 Graph Theory Victor Adamchik Fall of 2005 Plan 1. Basic Vocabulary 2. Regular graph 3. Connectivity 4. Representing Graphs Introduction A.Aho and J.Ulman acknowledge that Fundamentally, computer
GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: 3330704)
GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT Course Curriculum DATA STRUCTURES (Code: 3330704) Diploma Programme in which this course is offered Semester in which offered Computer Engineering,
International Journal of Advanced Research in Computer Science and Software Engineering
Volume 3, Issue 7, July 23 ISSN: 2277 28X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Greedy Algorithm:
Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, 2010. Chapter 7: Digraphs
MCS-236: Graph Theory Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, 2010 Chapter 7: Digraphs Strong Digraphs Definitions. A digraph is an ordered pair (V, E), where V is the set
From Last Time: Remove (Delete) Operation
CSE 32 Lecture : More on Search Trees Today s Topics: Lazy Operations Run Time Analysis of Binary Search Tree Operations Balanced Search Trees AVL Trees and Rotations Covered in Chapter of the text From
The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).
CHAPTER 5 The Tree Data Model There are many situations in which information has a hierarchical or nested structure like that found in family trees or organization charts. The abstraction that models hierarchical
CS711008Z Algorithm Design and Analysis
CS711008Z Algorithm Design and Analysis Lecture 7 Binary heap, binomial heap, and Fibonacci heap 1 Dongbo Bu Institute of Computing Technology Chinese Academy of Sciences, Beijing, China 1 The slides were
Load balancing Static Load Balancing
Chapter 7 Load Balancing and Termination Detection Load balancing used to distribute computations fairly across processors in order to obtain the highest possible execution speed. Termination detection
Big Data and Scripting. Part 4: Memory Hierarchies
1, Big Data and Scripting Part 4: Memory Hierarchies 2, Model and Definitions memory size: M machine words total storage (on disk) of N elements (N is very large) disk size unlimited (for our considerations)
Data Structures, Practice Homework 3, with Solutions (not to be handed in)
Data Structures, Practice Homework 3, with Solutions (not to be handed in) 1. Carrano, 4th edition, Chapter 9, Exercise 1: What is the order of each of the following tasks in the worst case? (a) Computing
Data Structures Fibonacci Heaps, Amortized Analysis
Chapter 4 Data Structures Fibonacci Heaps, Amortized Analysis Algorithm Theory WS 2012/13 Fabian Kuhn Fibonacci Heaps Lacy merge variant of binomial heaps: Do not merge trees as long as possible Structure:
Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child
Binary Search Trees Data in each node Larger than the data in its left child Smaller than the data in its right child FIGURE 11-6 Arbitrary binary tree FIGURE 11-7 Binary search tree Data Structures Using
Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010
Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010 Problem 1. In each of the following question, please specify if the statement
Algorithms Chapter 12 Binary Search Trees
Algorithms Chapter 1 Binary Search Trees Outline Assistant Professor: Ching Chi Lin 林 清 池 助 理 教 授 [email protected] Department of Computer Science and Engineering National Taiwan Ocean University
Java Software Structures
INTERNATIONAL EDITION Java Software Structures Designing and Using Data Structures FOURTH EDITION John Lewis Joseph Chase This page is intentionally left blank. Java Software Structures,International Edition
Rotation Operation for Binary Search Trees Idea:
Rotation Operation for Binary Search Trees Idea: Change a few pointers at a particular place in the tree so that one subtree becomes less deep in exchange for another one becoming deeper. A sequence of
Network (Tree) Topology Inference Based on Prüfer Sequence
Network (Tree) Topology Inference Based on Prüfer Sequence C. Vanniarajan and Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology Madras Chennai 600036 [email protected],
Exercises Software Development I. 11 Recursion, Binary (Search) Trees. Towers of Hanoi // Tree Traversal. January 16, 2013
Exercises Software Development I 11 Recursion, Binary (Search) Trees Towers of Hanoi // Tree Traversal January 16, 2013 Software Development I Winter term 2012/2013 Institute for Pervasive Computing Johannes
Data Structures. Chapter 8
Chapter 8 Data Structures Computer has to process lots and lots of data. To systematically process those data efficiently, those data are organized as a whole, appropriate for the application, called a
Heaps & Priority Queues in the C++ STL 2-3 Trees
Heaps & Priority Queues in the C++ STL 2-3 Trees CS 3 Data Structures and Algorithms Lecture Slides Friday, April 7, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks
Approximation Algorithms
Approximation Algorithms or: How I Learned to Stop Worrying and Deal with NP-Completeness Ong Jit Sheng, Jonathan (A0073924B) March, 2012 Overview Key Results (I) General techniques: Greedy algorithms
Binary Trees. Wellesley College CS230 Lecture 17 Thursday, April 5 Handout #28. PS4 due 1:30pm Tuesday, April 10 17-1
inary Trees Wellesley ollege S230 Lecture 17 Thursday, pril 5 Handout #28 PS4 due 1:30pm Tuesday, pril 10 17-1 Motivation: Inefficiency of Linear Structures Up to this point our focus has been linear structures:
Scheduling Shop Scheduling. Tim Nieberg
Scheduling Shop Scheduling Tim Nieberg Shop models: General Introduction Remark: Consider non preemptive problems with regular objectives Notation Shop Problems: m machines, n jobs 1,..., n operations
Operations: search;; min;; max;; predecessor;; successor. Time O(h) with h height of the tree (more on later).
Binary search tree Operations: search;; min;; max;; predecessor;; successor. Time O(h) with h height of the tree (more on later). Data strutcure fields usually include for a given node x, the following
Chinese postman problem
PTR hinese postman problem Learning objectives fter studying this chapter, you should be able to: understand the hinese postman problem apply an algorithm to solve the problem understand the importance
Algorithms and data structures
Algorithms and data structures This course will examine various data structures for storing and accessing information together with relationships between the items being stored, and algorithms for efficiently
Binary Heap Algorithms
CS Data Structures and Algorithms Lecture Slides Wednesday, April 5, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks [email protected] 2005 2009 Glenn G. Chappell
Graph Theory Problems and Solutions
raph Theory Problems and Solutions Tom Davis [email protected] http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is
Load Balancing and Termination Detection
Chapter 7 Load Balancing and Termination Detection 1 Load balancing used to distribute computations fairly across processors in order to obtain the highest possible execution speed. Termination detection
Data Structures and Data Manipulation
Data Structures and Data Manipulation What the Specification Says: Explain how static data structures may be used to implement dynamic data structures; Describe algorithms for the insertion, retrieval
Euclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li. Advised by: Dave Mount. May 22, 2014
Euclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li Advised by: Dave Mount May 22, 2014 1 INTRODUCTION In this report we consider the implementation of an efficient
A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:
Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)
ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION 2008-10-23/5:15-6:45 REC-200, EVI-350, RCH-106, HH-139
ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION 2008-10-23/5:15-6:45 REC-200, EVI-350, RCH-106, HH-139 Instructions: No aides. Turn off all electronic media and store them under your desk. If
CSE 326: Data Structures B-Trees and B+ Trees
Announcements (4//08) CSE 26: Data Structures B-Trees and B+ Trees Brian Curless Spring 2008 Midterm on Friday Special office hour: 4:-5: Thursday in Jaech Gallery (6 th floor of CSE building) This is
Practical Graph Mining with R. 5. Link Analysis
Practical Graph Mining with R 5. Link Analysis Outline Link Analysis Concepts Metrics for Analyzing Networks PageRank HITS Link Prediction 2 Link Analysis Concepts Link A relationship between two entities
Data Structures Using C++
Data Structures Using C++ 1.1 Introduction Data structure is an implementation of an abstract data type having its own set of data elements along with functions to perform operations on that data. Arrays
Introduction to Data Structures and Algorithms
Introduction to Data Structures and Algorithms Chapter: Elementary Data Structures(1) Lehrstuhl Informatik 7 (Prof. Dr.-Ing. Reinhard German) Martensstraße 3, 91058 Erlangen Overview on simple data structures
Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs
Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs Kousha Etessami U. of Edinburgh, UK Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 1 / 13 Overview Graphs and Graph
Sample Questions Csci 1112 A. Bellaachia
Sample Questions Csci 1112 A. Bellaachia Important Series : o S( N) 1 2 N N i N(1 N) / 2 i 1 o Sum of squares: N 2 N( N 1)(2N 1) N i for large N i 1 6 o Sum of exponents: N k 1 k N i for large N and k
Mathematics for Algorithm and System Analysis
Mathematics for Algorithm and System Analysis for students of computer and computational science Edward A. Bender S. Gill Williamson c Edward A. Bender & S. Gill Williamson 2005. All rights reserved. Preface
A Fast Algorithm For Finding Hamilton Cycles
A Fast Algorithm For Finding Hamilton Cycles by Andrew Chalaturnyk A thesis presented to the University of Manitoba in partial fulfillment of the requirements for the degree of Masters of Science in Computer
Solutions to Homework 6
Solutions to Homework 6 Debasish Das EECS Department, Northwestern University [email protected] 1 Problem 5.24 We want to find light spanning trees with certain special properties. Given is one example
Binary Heaps * * * * * * * / / \ / \ / \ / \ / \ * * * * * * * * * * * / / \ / \ / / \ / \ * * * * * * * * * *
Binary Heaps A binary heap is another data structure. It implements a priority queue. Priority Queue has the following operations: isempty add (with priority) remove (highest priority) peek (at highest
Data Structures and Algorithm Analysis (CSC317) Intro/Review of Data Structures Focus on dynamic sets
Data Structures and Algorithm Analysis (CSC317) Intro/Review of Data Structures Focus on dynamic sets We ve been talking a lot about efficiency in computing and run time. But thus far mostly ignoring data
The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,
The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints
Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits
Outline NP-completeness Examples of Easy vs. Hard problems Euler circuit vs. Hamiltonian circuit Shortest Path vs. Longest Path 2-pairs sum vs. general Subset Sum Reducing one problem to another Clique
Optimal Binary Search Trees Meet Object Oriented Programming
Optimal Binary Search Trees Meet Object Oriented Programming Stuart Hansen and Lester I. McCann Computer Science Department University of Wisconsin Parkside Kenosha, WI 53141 {hansen,mccann}@cs.uwp.edu
EE602 Algorithms GEOMETRIC INTERSECTION CHAPTER 27
EE602 Algorithms GEOMETRIC INTERSECTION CHAPTER 27 The Problem Given a set of N objects, do any two intersect? Objects could be lines, rectangles, circles, polygons, or other geometric objects Simple to
Row Echelon Form and Reduced Row Echelon Form
These notes closely follow the presentation of the material given in David C Lay s textbook Linear Algebra and its Applications (3rd edition) These notes are intended primarily for in-class presentation
Full and Complete Binary Trees
Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full
6 March 2007 1. Array Implementation of Binary Trees
Heaps CSE 0 Winter 00 March 00 1 Array Implementation of Binary Trees Each node v is stored at index i defined as follows: If v is the root, i = 1 The left child of v is in position i The right child of
Load Balancing and Termination Detection
Chapter 7 slides7-1 Load Balancing and Termination Detection slides7-2 Load balancing used to distribute computations fairly across processors in order to obtain the highest possible execution speed. Termination
