Data Structures Flashcards
What is an array?
An array is a data structure of fixed-size, which can hold items of the same data type.
Why do arrays in JavaScript not have a fixed-size?
This is because arrays in JS are actually objects, whose keys are strings that look like non-negative numbers.
What is a linked list?
A linked list is a data structure that consists of a sequence of items in linear other that are linked to each other.
What are data structures?
Data structures are data organisation, management and storage formats that allow for efficient data access and management.
Describe the different parts that make up a linked list.
All the elements in a linked list are known as nodes. Each node contains a key and a pointer to its successor node, known as next. The beginning of the linked list is stored in a head pointer, which points to the first node. The end of the list of the list is stored in a tail pointer, which points to the last node.
What are three types of linked lists?
Singly linked list, doubly linked list, and circular linked list.
What is a singly linked list?
It is a linked list that can be done in the forward direction only.
What is a doubly linked list?
It is a linked list that can be done in both forward and backward directions. The nodes in this list will contain an additional pointer known as ‘prev’.
What is a circular linked list?
It is a linked list where the prev pointer of the head points to the tail, and the next pointer of the tail points to the head.
What three operations can be performed on a linked list?
Search, Insert, and Delete.
What does the Search operation on a linked list do?
The search operation will find the first element with the matching given key by doing a linear search and will return a pointer to this element.
What does the Insert operation on a linked list do and what are the three ways this can be done?
The insert operation will insert a given key into to the linked list. A key can be inserted at the beginning of the list, the end of the list and the middle of the list.
What does the Delete operation on a linked list do and what are the three ways this can be done?
The delete operation removes an element with the matching given key from a linked list. A key can be inserted at the beginning of the list, the end of the list and the middle of the list.
What is a Hash Map/Table?
A hash map is a data structure that stores values that have keys associated with them.
What is a hash function and how does it work?
A hash function is a function used to map data of arbitrary size to one of a fixed size. The function works by calculating a hash value for a given key, which indicates the index of a map/table to which the value will be mapped.