Data Structures Quiz 2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is a Queue

- A restricted access linear data structure - Items are removed in the order they are added - FIFO

Applications of Stacks:

- Evaluating expressions and parsing syntax - Balancing delimiters in program code - Converting numbers between bases - Processing financial data - Backtracking algorithms

How is a Queue different than a Stack?

- In a queue, both ends are involved. Additions are restricted to one end (the rear) and deletions to the other end (the front)

What data members does a stack need?

- List of items - Length - Max size

What is a Stack?

- a restricted linear data structure - LIFO - can only be accessed at one of its ends for adding and removing elements - Stacks are lists w/ restricted insertion and removal

What information does the activation record, or stack frame, contain?

- values of the function's parameters, addresses of reference variables - copies of local variables - the return address of the calling function - A dynamic link to the calling function's activation record - the function's return value if it is not void

For recursion the following must be true:

1. There must be some base condition for which the subprogram does not call itself 2. Each time the subprogram calls itself, it must converge on the base condition

What is a search table?

A dictionary implemented by means of a sorted sequence

What is Recursion?

A problem-solving approach in which a problem is solved by repeatedly applying the same solution to smaller instances

Binary search best-case time complexity:

O(1) - when target element happens to be in the middle of the array

Linear search time complexity, best case?

O(1) - when the target element v is the first element in the array

Binary search average-case time complexity:

O(log n)

Binary search worst-case time complexity:

O(log n)

Linear search time complexity, average case?

O(n) - if the target is somewhere in the middle of the array

What does the fact that in recursion the sub-problem is of the same form as the original mean to the programmer?

The function can call itself to solve it

How can one implement a Stack?

Using an array, a vector, or a linked list

Linear search time complexity, worst case?

Worst-case: O(n) - if v does not exist or if v is the last element in the array


Kaugnay na mga set ng pag-aaral

HVAC Refrigerants and Lubricants Unit 16 Test

View Set

Values, Ethics, and Advocacy PrepU

View Set

Cloud Computing Final Study Guide

View Set

HIST 2162 - Soviet History - Quotes List With Questions

View Set