DSA (MIDTERMS)

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/26

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

27 Terms

1
New cards

Bubble Sort

Is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order.

2
New cards

Selection Sort

  • An array by repeatedly finding the minimum element considering ascending order.

  •  is an in-place comparison-based algorithm in which the list is divided into two parts, the sorted part at the left end and the unsorted part at the right end.

  • This algorithm is not suitable for large data sets as it is average and worst-case complexities are of Ο(n2), where n is the number of items.

3
New cards

Insertion Sort

  • is an in-place comparison-based sorting algorithm.  Here, a sub-list is maintained, which is always sorted.

  • This algorithm is not suitable for large data sets as its average and worst-case complexity are of Ο(n2), where n is the number of items.

4
New cards

Shell Sort

  •  is a highly efficient sorting algorithm and is based on the insertion sort algorithm.  This algorithm avoids large shifts as in the case of insertion sort if the smaller value is to the far right and has to be moved to the far left

  • This algorithm is quite efficient for medium-sized data sets as its average and worst-case complexity of this algorithm depends on the gap sequence the best known is Ο(n), where n is the number of items. And the worst-case space complexity is O(n).

  • It uses insertion sort on widely spread elements, first to sort them and then sorts the less widely spaced elements. The spacing is termed as an interval.  The interval is calculated based on Knuth's formula as 

5
New cards

Heap Sort

  • is a comparison-based sorting algorithm. Heapsort can be thought of as an improved selection sort.  Like selection sort, heapsort divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element from it and inserting it into the sorted region. 

  • Although somewhat slower in practice on most machines than quicksort, it has the advantage of a more favorable worst-case O(n log n) runtime.

6
New cards

Merge Sort 

  • is a divide and conquer algorithm. It divides the input array into two halves, calls itself for the two halves, and then merges the two sorted halves. 

  • The time complexity of Merge Sort is O(nLogn) in all 3 cases; worst, average, and best as merge sort always divides the array into two halves and takes linear time to merge two halves.

7
New cards

Quick Sort

  • is a divide and conquer algorithm. It picks an element as a pivot and partitions the given array around the picked pivot. 

8
New cards

Bucket Sort

Bin, also referred to as Bucket Sort runs in linear time on average. Like Counting Sort, bucket Sort is fast because it considers something about the input.

9
New cards

Radix Sort

  • is one of the sorting algorithms used to sort a list of integer numbers in order.  In the radix sort algorithm, a list of integer numbers is sorted based on the digits of individual numbers.  Sorting is performed from the least significant digit to the most significant digit.

10
New cards

QUEUE

is an n ordered list in which all insertions take place at one end, the rear, while all deletions take place at the other end, the front.  It is an example of a linear data structure.

11
New cards

First-in, First-Out (FIFO)

Has (BLANK) structure where elements can only be added to the rear of the queue and removed from the front of the queue.

12
New cards
  • Enqueue

  • For insertions

13
New cards

  • Dequeue 

  •  For deletion

14
New cards
  • Adds an item onto the end of the queue. 

enqueue(new-item:item-type)

15
New cards
  •  Removes the item from the front of the queue

dequeue()

16
New cards
  • Returns the item at the front of the queue

front():item-type

17
New cards
  • Returns the item at the front of the queue

back()

18
New cards
  • True if no more items can be dequeued and there is no front item.

is-empty()Boolean

19
New cards

 True if no more items can

Is-full(): Boolean

20
New cards

 Pushes a new element to the end of the queue.

push(newElement)

21
New cards
  •  Removes but does not return the element at the front of the queue

pop()

22
New cards
  • Returns the number of elements in the queue

get-sizer():integer

23
New cards

LINKEDLIST

  • is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers.  A linked list consists of nodes where each node contains a data field and a reference(link) to the next node in the list.

24
New cards

SINGLY LINKED LIST
DOUBLY LINKED LIST

CIRCULAR LINKED LIST

3 Types of LinkedList

25
New cards

Singly Linked List

  • is the most common form of a Linked List where each node contains a data field and a single pointer to the next node in the list.

  • The reference to the first node in the list is called the HEAD of the list. The pointer/reference/link field contained in the node is used to traverse to the next node and to its next node and so on till we reach a node that points to NULL. This is the last node in the list.  Also, a singly linked list can only be traversed in one and only one direction i.e. from head to the last node. There is no way to traverse from the last node back to the head.

26
New cards

Doubly Linked List

  • is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains two fields, called links, that are references to the previous and to the next node in the sequence of nodes.

27
New cards

Circular Linked List

  • is a linked list where all nodes are connected to form a circle. There is no NULL at the end. A circular linked list can be a singly circular linked list or a doubly circular linked list.