2022 p1 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Big-O time complexity for Bubble sort

A

O(n^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Big-O time complexity for Linear search

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Big-O time complexity for Merge sort

A

O(nlogn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe the method that would need to be followed to attempt to remove an item from a circular queue implemented as a static data structure using an array

A
  1. check if the queue is empty by comparing the front and rear pointer. if equal, the queue is empty and no item can be removed.
  2. if not empty, remove the front item from the front of the queue.
  3. update the front pointer to the next item in the queue. if the front pointer exceeds the size of the array, reset it to 0.
  4. reduce the count of items in the queue by 1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

three differences between dynamic and static data structures

A

static data structures memory are allocated at compile time/dynamic data structure memory are allocated at run time.

static data structure size is fixed and cannot change during runtime/ dynamic data structure size can be changed during runtime

static data structure memory is managed by compiler/ dynamic data structure memory is managed by the programmer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

explain how a single stack can be used to reverse the order of the items in a queue

A
  1. deque all the items from the queue and push them onto the stack
  2. pop them off one by one and enqueue them back into the original queue
  3. the order of the items in the queue will be reversed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly