CP 114 W07 Midterm Review - CP 114 W07 Midterm Review wluphi.org Definitions Auxiliary function Recursive function called by parent function Usually

CP 114 W07 Midterm Review - CP 114 W07 Midterm Review...

This preview shows page 1 - 4 out of 8 pages.

CP 114 W07 Midterm Review wluphi.org Definitions Auxiliary function Recursive function called by parent function. Usually requiring more or different parameters than the parent. Sum(n) can have an auxiliary function Sum(m,n) which sums integers from 1 to n recursively. Sum(n) itself cannot do going up recursion because it has a fixed left limit The recursive function Find(tree, element) would call find_aux(tree.root, element). Find_aux(node, element) would then call find_aux(node.left/node.right, element) Call Tree A call tree shows how function calls are generated. Descendents of a function call are further recursive calls. Calls in the tree with no descendants involve evaluations of a base case. eg. Fibonacci: F(n)= F(n-1) + F(n-2); F(1)=F(0)=1 F(3) / \ F(2) F(1) / \ F(1) F(0) Big- O Notation/ Complexity Classes F(x)>=c*g(x) FIFO First in, First out. The first element into an ADT is the first element out. The nature of Queues LIFO The last item inserted is the first item removed. The nature of Stacks
Image of page 1

Subscribe to view the full document.

Abstract Data type A collection of data entities along with functions defined on those entities. Example: stack ADT auxiliary function-a function which accompanies another function and does a task for it. We often used it in the context of recursion. Linked List See Data Structures Linked List String of students in lab with names (data) and pointers to next node (arm/hand/finger pointing) Stack See Data Structures Stack Can of Pringles chips Queue See Data Structures Queue Line-up at Time Horton’s. Priority Queue See Data Structures Priority Queue Hospital emergency room waiting room in which the sickest patients are seen first, i.e. patients of highest priority are those that are the sickest. Binary Search Trees See Data Structures BST Level (of a tree) Level (of a tree)-(recursive definition) the root has level zero. The nodes at level i are the children of the nodes at level i-1. x Level 0 / \ x x Level 1 Internal Node A node that has children e / \ z w / \ / \ x y d a
Image of page 2
/ \ b c In this example, w is an internal node. A note on Data Abstraction Consider ADTs to be similar to a bank machine. When you put money in, it takes the money from you and tells you that you have more in your account. When you take money out, it gives you cash, and tells you that you have less in your account. When you use the machine, you ask it for $20, take the bill from the slot, and put it in your pocket. What you don’t do is tell it to check your balance to see
Image of page 3

Subscribe to view the full document.

Image of page 4
  • Fall '13
  • sta

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes