
Sample Final with solutions
... • Please check that your exam is complete. It should have 19 pages in total • The examination has a total of 100 marks • This is an open textbook/lecture notes exam. You can consult your notes/textbook but you cannot talk/communicate with other students. Exam/homework solutions are not allowed durin ...
... • Please check that your exam is complete. It should have 19 pages in total • The examination has a total of 100 marks • This is an open textbook/lecture notes exam. You can consult your notes/textbook but you cannot talk/communicate with other students. Exam/homework solutions are not allowed durin ...
Lecture 4 1 Overview 2 Splay Tree Properties
... The proof of this property is very long and complex and is beyond the scope of this class. It has been recently simplified and expanded [IL16]. Property 4. (Working set) [ST85]: The amortized cost of searching for x in a splay tree is O(1 + log tx ), where tx is the number of distinct elements searc ...
... The proof of this property is very long and complex and is beyond the scope of this class. It has been recently simplified and expanded [IL16]. Property 4. (Working set) [ST85]: The amortized cost of searching for x in a splay tree is O(1 + log tx ), where tx is the number of distinct elements searc ...
Data Structures and Algorithms(6)
... tag rtag, then it is called “double-tagging preorder sequence representation”. Each node includes data and 2 tags(ltag and rtag), the form of the node is like: ltag info rtag According to the preorder sequence and 2 tags(ltag, rtag), we can calculate the value of llink and rlink of each node in the ...
... tag rtag, then it is called “double-tagging preorder sequence representation”. Each node includes data and 2 tags(ltag and rtag), the form of the node is like: ltag info rtag According to the preorder sequence and 2 tags(ltag, rtag), we can calculate the value of llink and rlink of each node in the ...
Advanced pointers and structures
... – Pointers to two children nodes (left and right) • 2 pointers == binary • Left node pointer points to a node with data that is less than the current node • Right node pointer points to a node with data that is greater than the current node • All nodes to the left contain data less • All nodes to th ...
... – Pointers to two children nodes (left and right) • 2 pointers == binary • Left node pointer points to a node with data that is less than the current node • Right node pointer points to a node with data that is greater than the current node • All nodes to the left contain data less • All nodes to th ...
Non-Linear Data Structures - Trees
... If the node to be deleted is the root node of the BST, then we have a problem. The problem is that Java passes parameters by value. Any change made to the root reference by this method e.g., such that it references the new root node of the merged subtrees, does not affect the reference to the root n ...
... If the node to be deleted is the root node of the BST, then we have a problem. The problem is that Java passes parameters by value. Any change made to the root reference by this method e.g., such that it references the new root node of the merged subtrees, does not affect the reference to the root n ...
Sample questions Paper
... Answer: Stack. Because of its LIFO (Last In First Out) property it remembers its 'caller' so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls. Every recursive function has its equivalent iterative (non-re ...
... Answer: Stack. Because of its LIFO (Last In First Out) property it remembers its 'caller' so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls. Every recursive function has its equivalent iterative (non-re ...
Chapter 10: Efficient Collections (skip lists, trees)
... nothing can beat the constant time performance of a simple dynamic array or linked list. But if searching or removals are common, then the O(log n) cost of searching an ordered list may more than make up for the slower cost to perform an insertion. Imagine, for example, an on-line telephone director ...
... nothing can beat the constant time performance of a simple dynamic array or linked list. But if searching or removals are common, then the O(log n) cost of searching an ordered list may more than make up for the slower cost to perform an insertion. Imagine, for example, an on-line telephone director ...
Final exam. Spring`03 (Yen)
... Suppose that the root r of a binomial tree has 6 children. How many grandchildren does r have? (Note: a grandchild of r means a child of a child of r.) Answer: 15 2. Write down the worst-case running times of the following: (a) quicksort, (b) decrease-key for pairing heaps. Answer: (a) O(n2), (b) O( ...
... Suppose that the root r of a binomial tree has 6 children. How many grandchildren does r have? (Note: a grandchild of r means a child of a child of r.) Answer: 15 2. Write down the worst-case running times of the following: (a) quicksort, (b) decrease-key for pairing heaps. Answer: (a) O(n2), (b) O( ...
Tree Introduction
... • If wrong “learn” new animal by asking for a yes/no question that distinguishes the new animal from the guess ...
... • If wrong “learn” new animal by asking for a yes/no question that distinguishes the new animal from the guess ...
Data Structures and Algorithms IT2003
... root, then search the left subtree 5) (5) If it is greater than the value stored at the root, then search the right subtree 6) (6) Repeat steps 2-6 for the root of the subtree chosen in the previous step 4 or 5 Is this better than searching a linked list? ...
... root, then search the left subtree 5) (5) If it is greater than the value stored at the root, then search the right subtree 6) (6) Repeat steps 2-6 for the root of the subtree chosen in the previous step 4 or 5 Is this better than searching a linked list? ...
The data structures presented so far are linear in that items are one
... the children of a root node is at level 2 and so on. If we consider the expression tree given in the previous slide this has 4 levels. Using this notion of level instead of the conventional notion of depth of a node, we can provide a recursive definition of height of a tree, as shown in this slide. ...
... the children of a root node is at level 2 and so on. If we consider the expression tree given in the previous slide this has 4 levels. Using this notion of level instead of the conventional notion of depth of a node, we can provide a recursive definition of height of a tree, as shown in this slide. ...
trees - Omieno Kelvin
... lowest level. (An additional quarter of these operations require finding the node on the next-to-lowest level, and so on.) During a search we need to visit one node on each level. So we can get a good idea how long it takes to carry out these operations by knowing how many levels there are. Assuming ...
... lowest level. (An additional quarter of these operations require finding the node on the next-to-lowest level, and so on.) During a search we need to visit one node on each level. So we can get a good idea how long it takes to carry out these operations by knowing how many levels there are. Assuming ...
Binary search tree
In computer science, binary search trees (BST), sometimes called ordered or sorted binary trees, are a particular type of containers: data structures that store ""items"" (such as numbers, names and etc.) in memory. They allow fast lookup, addition and removal of items, and can be used to implement either dynamic sets of items, or lookup tables that allow finding an item by its key (e.g., finding the phone number of a person by name).Binary search trees keep their keys in sorted order, so that lookup and other operations can use the principle of binary search: when looking for a key in a tree (or a place to insert a new key), they traverse the tree from root to leaf, making comparisons to keys stored in the nodes of the tree and deciding, based on the comparison, to continue searching in the left or right subtrees. On average, this means that each comparison allows the operations to skip about half of the tree, so that each lookup, insertion or deletion takes time proportional to the logarithm of the number of items stored in the tree. This is much better than the linear time required to find items by key in an (unsorted) array, but slower than the corresponding operations on hash tables.They are a special case of the more general B-tree with order equal to two.