Essentials Flashcards

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

What is an abstract data type

A

An abstract data type is defined as a logical description of how data is viewed and the operations that can be performed on it but how this is done is not neccesarily known to the user

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

How do you insert a node in a singly linked list?

A

to insert a new element at the beginning of a singly linked list create a new node, point its ‘next’ to the current head and update the head pointer.

Insertion at the end: traverse the list until you find the last node, create a new node and make the last node point to the new node

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

How to delete a node in singly linked list

A

Deletion of a specific node: Traverse the list to find the node to be deleted and update the ‘next’ pointers accordingly

Deletion at the beginning: Update the head pointer to the next node

Deletion at the end: Traverse the list to find the second to last node make it point to NULL and free the last node.

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

How to traverse a node:

A

To access and process all elements in the list start at the head and traverse the list by following the ‘next’ pointers until NULL is encountered

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

Briefly describe the bubble sort algorithm

A

The bubble sort algorithm compares 2 succesive elements repeatedly and swaps if necessary. If the user wants to sort in ascending order then the comparion is made between two elements and the smaller element placed at first place

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

Briefly describe binary search

A

A fast way to search a sorted array is to use binary search. The idea is to look at the element in the middle, if the key is greater than that do a binary search on the second half, if the key is less than that do a binary search on the first half and if the key is already equal the search is finished

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