Data Structures SEBI

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

1/487

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

488 Terms

1
New cards

What is an array

A collection of homogeneous elements stored in contiguous memory locations

2
New cards

What type of memory storage does an array use

Contiguous memory

3
New cards

Is array indexing zero based

Yes indexing usually starts from zero

4
New cards

What is the base address in arrays

Address of the first element of the array

5
New cards

How is address of arr i calculated

Base address plus i multiplied by size of element

6
New cards

What is a static array

Array whose size is fixed at compile time

7
New cards

Give example of static array in C

int arr[10]

8
New cards

What is a dynamic array

Array whose size is allocated at runtime

9
New cards

Name one dynamic array implementation in Java

ArrayList

10
New cards

Name one dynamic array implementation in C plus plus

Vector

11
New cards

What is time complexity of accessing an array element

O one

12
New cards

Why is array access O one

Direct access using index

13
New cards

What is time complexity of linear search in array

O n

14
New cards

When is linear search used

When array is unsorted

15
New cards

What is time complexity of binary search

O log n

16
New cards

What is prerequisite for binary search

Array must be sorted

17
New cards

What is worst case time complexity of insertion in array

O n

18
New cards

Why insertion worst case is O n

Elements need shifting

19
New cards

What is worst case time complexity of deletion in array

O n

20
New cards

When does deletion take O n time

Deleting from beginning of array

21
New cards

What is a two dimensional array

Array with rows and columns

22
New cards

How is 2D array stored in memory

Flattened into one dimensional memory

23
New cards

What is row major order

Elements stored row by row

24
New cards

Which language uses row major order by default

C language

25
New cards

What is column major order

Elements stored column by column

26
New cards

Which language uses column major order

Fortran

27
New cards

What is two pointer technique

Uses two indices moving towards each other

28
New cards

Give one use of two pointer technique

Reversing an array

29
New cards

What is sliding window technique

Maintains a window of elements for subarray problems

30
New cards

Give one use of sliding window

Finding subarray with given sum

31
New cards

What is Kadane algorithm used for

Finding maximum sum contiguous subarray

32
New cards

What is time complexity of Kadane algorithm

O n

33
New cards

What is Dutch National Flag algorithm used for

Sorting array of zeros ones and twos

34
New cards

What is time complexity of Dutch National Flag algorithm

O n

35
New cards

What is a sparse matrix

Matrix with most elements as zero

36
New cards

Why sparse matrix representation is used

To save memory space

37
New cards

What is triplet representation

Stores row column and value

38
New cards

What is array overflow

Insertion into a full static array

39
New cards

What is array underflow

Deletion from an empty array

40
New cards

What does arr represent in C

Constant pointer to first element

41
New cards

What is arr equivalent to

&arr[0]

42
New cards

What is equivalent of arr[i] in pointer arithmetic

*(arr plus i)

43
New cards

What is a linked list

Collection of nodes stored in non contiguous memory

44
New cards

How is linked list memory allocated

Dynamically at runtime

45
New cards

How does array memory differ from linked list

Array uses contiguous memory

46
New cards

What type of access does array support

Random access

47
New cards

What type of access does linked list support

Sequential access

48
New cards

What is access time of linked list

O n

49
New cards

Why linked list access is O n

Traversal required from head

50
New cards

What is insertion time in linked list if pointer is known

O one

51
New cards

Why insertion in array is O n

Shifting of elements required

52
New cards

What extra memory does linked list use

Extra space for pointer

53
New cards

What is a singly linked list

Each node has data and next pointer

54
New cards

What is a doubly linked list

Each node has data next and prev pointers

55
New cards

What advantage does doubly linked list have

Bidirectional traversal

56
New cards

What is a circular linked list

Last node points to head

57
New cards

What is application of circular linked list

Round robin CPU scheduling

58
New cards

What is a doubly circular linked list

No null pointers in list

59
New cards

What is worst case search time in singly linked list

O n

60
New cards

What is worst case search time in doubly linked list

O n

61
New cards

What is time to insert at beginning in singly linked list

O one

62
New cards

What is time to insert at beginning in doubly linked list

O one

63
New cards

What is time to insert at end without tail pointer

O n

64
New cards

What is time to insert at end with tail pointer

O one

65
New cards

What is delete at end time in singly linked list

O n

66
New cards

Why delete at end is O n in singly linked list

Must find previous node

67
New cards

What is delete at end time in doubly linked list if tail known

O one

68
New cards

What is time complexity of reversing singly linked list

O n

69
New cards

How many pointers needed to reverse singly linked list

Three pointers

70
New cards

Name the three pointers used in reversal

Prev curr and next

71
New cards

What is head insertion pointer logic

newNode next points to head

72
New cards

After insertion how is head updated

Head points to new node

73
New cards

What is trick to delete a node given pointer p

Copy next node data and bypass it

74
New cards

Which node cannot be deleted using trick

Last node

75
New cards

What is Floyd cycle detection algorithm

Detects loop in linked list

76
New cards

What are pointers used in Floyd algorithm

Slow and fast pointers

77
New cards

How many steps slow pointer moves

One step

78
New cards

How many steps fast pointer moves

Two steps

79
New cards

What indicates presence of cycle

Slow and fast pointers meet

80
New cards

What is a self referential structure

Structure containing pointer to same type

81
New cards

Why linked list node is self referential

Next points to same structure type

82
New cards

What does struct Node next represent

Address of next node

83
New cards

What is size of node on 32 bit system

Data plus pointer size

84
New cards

Why linked lists are good for sparse matrices

Saves space by storing non zero elements

85
New cards

Why linked lists suit polynomial representation

Efficient for many zero coefficients

86
New cards

What is a stack

Linear data structure following LIFO principle

87
New cards

What does LIFO stand for

Last in first out

88
New cards

Which element can be accessed in stack

Only the top element

89
New cards

What is push operation

Insertion of element at top of stack

90
New cards

What is pop operation

Removal of top element from stack

91
New cards

What is peek operation

Returns top element without removing it

92
New cards

What does isEmpty check

Whether stack is empty

93
New cards

What does isFull check

Whether stack is full

94
New cards

What is time complexity of push

O one

95
New cards

What is time complexity of pop

O one

96
New cards

What is time complexity of peek

O one

97
New cards

What is stack overflow

Push operation on full stack

98
New cards

In which implementation overflow occurs

Array based stack

99
New cards

What is stack underflow

Pop operation on empty stack

100
New cards

Which stack implementation avoids overflow

Linked list based stack