Collision. When A Hash Function Maps Two Different Keys To The Same Table Address

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

 

the worst-case complexity (usually denoted in asymptotic notation) measures the resources


(e.g. running time, memory) that an algorithm requires given an input of arbitrary size
(commonly denoted as n or N). It gives an upper bound on the resources required by
the algorithm

collision. When a hash function maps two different keys to the same table address,


a collision is said to occur. linear probing. A simple re-hashing scheme in which the next slot
in the table is checked on a collision

Queue Application: Queue is used when things don't have to be processed immediately, but
have to be processed in First In First Out order like Breadth First Search. This property
of Queue makes it also useful in following kind of scenarios. 1) When a resource is shared
among multiple consumers

Dense graph is a graph in which the number of edges is close to the maximal number of
edges. Sparse graph is a graph in which the number of edges is close to the minimal number
of edges. Sparse graph can be a disconnected graph.

In linear data structure, data elements are sequentially connected and each element is


traversable through a single run. In non-linear data structure, data elements are hierarchically
connected and are present at various levels. ... Linear data structures can be traversed
completely in a single run

 Directed Graphs. ...
 Vertex labeled Graphs. ...
 Cyclic Graphs. ...
 Edge labeled Graphs. ...
 Weighted Graphs. ...
 Directed Acyclic Graphs. ...
 Disconnected Graphs

Traversal is a process to visit all the nodes of a tree and may print their values too. Because,
all nodes are connected via edges (links) we always start from the root (head) node. That is, we
cannot randomly access a node in a tree. There are three ways which we use
to traverse a tree − In-order Traversal.
AVL tree is the self balancing tree. The binary search tree which is unbalanced undergoes
some operation to get converted into balanced BT. The time complexity for searching an
element in skewed bst is worst. So such trees are converted to AVL tree
AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of
left and right subtrees cannot be more than one for all nodes. The above tree is AVL because
differences between heights of left and right subtrees for every node is less than or equal to 1
A directed graph is graph, i.e., a set of objects (called vertices or nodes) that are connected
together, where all the edges are directed from one vertex to another. A directed graph is
sometimes called a digraph or a directed network.
An edge is where two faces meet. A vertex is a corner where edges meet. The plural
is vertices

Divide and conqucour:


Merge and quick

So, a need arises to balance out the existing BST. AVL trees are height balancing binary
search tree. AVL tree checks the height of the left and the right sub-trees and assures that the
difference is not more than 1. This difference is called the Balance Factor
Balance factor of a node is the difference between the heights of the left and right
subtrees of that node. The balance factor of a node is calculated either height of left
subtree - height of right subtree (OR) height of right subtree - height of left subtree.
a collision or clash is a situation that occurs when two distinct pieces of data have the
same hash value, checksum, fingerprint, or cryptographic digest. ... The impact
of collisions depends on the application.

a hash table (hash map) is a data structure that implements an associative array


abstract data type, a structure that can map keys to values. A hash table uses
a hash function to compute an index, also called a hash code, into an array of buckets or
slots, from which the desired value can be found

What is Data Structure and Algorithm:


A data structure is a named location that can be used to store and organize data. And,
an algorithm is a collection of steps to solve a particular problem. Learning data structures
and algorithms allow us to write efficient and optimized computer programs

Pseudocode
is a plain language description of the steps in an algorithm or another system. Pseudocode
often uses structural conventions of a normal programming language, but is intended for
human reading rather than machine reading.

If the user performing the update does not realize the data is stored redundantly
the update will not be done properly. A deletion anomaly is the unintended loss of data
due to deletion of other data. ... An insertion anomaly is the inability to add data to the
database due to absence of other data.

Bubble Sort 
is the simplest sorting algorithm that works by repeatedly swapping the adjacent
elements if they are in wrong order

Searching in data
-strucutre refers to the process of finding a desired element in set of items. ... The set of items to
be searched in, can be any data-structure like − list, array, linked-list, tree or graph. Search
refers to locating a desired element of specified properties in a collection of items

binary search,
also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that
finds the position of a target value within a sorted array. Binary search compares the target value to
the middle element of the array.

A Linear data structure 


have data elements arranged in sequential manner and each member element is connected to
its previous and next element. Such data structures are easy to implement as computer
memory is also sequential. ... Examples of linear data structures are List, Queue, Stack, Array
etc

Binary search is more efficient than linear search; it has a time complexity of O(log n). The
list of data must be in a sorted order for it to work. ..

Insertion:
Insertion sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is
much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or
merge sort

selection sort
is an in-place comparison sorting algorithm. It has an O(n²) time complexity, which makes it
inefficient on large lists, and generally performs worse than the similar insertion sort.
Merge Sort:
An example of merge sort. First divide the list into the smallest unit (1 element), then compare
each element with the adjacent list to sort and merge the two adjacent lists. ... In computer
science, merge sort (also commonly spelled merge sort) is an efficient, general-purpose,
comparison-based sorting algorithm.
merge sort is an efficient, general-purpose, comparison-based sorting algorithm. Most
implementations produce a stable sort, which means that the order of equal elements is the
same in the input and output

Quick Sort;

In simple QuickSort algorithm, we select an element as pivot, partition the array around pivot


and recur for subarrays on left and right of pivot. Consider an array which has many redundant
elements. For example, {1, 4, 2, 4, 2, 4, 1, 2, 4, 1, 2, 2, 2, 2, 4, 1, 4, 4, 4}. ... a) arr[l..i] elements
less than pivot

The shell sort,
sometimes called the “diminishing increment sort,” improves on the insertion sort by breaking
the original list into a number of smaller sublists, each of which is sorted using an
insertion sort. The unique way that these sublists are chosen is the key to the shell sort

Queue:
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is
open at both its ends. One end is always used to insert data (enqueue) and the other is used to
remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored
first will be accessed first.
A Queue is a linear structure which follows a particular order in which the operations are
performed. The order is First In First Out (FIFO). A good example of a queue is any queue of
consumers for a resource where the consumer that came first is served first. The difference
between stacks and queues is in removing.
Applications:
Queue is used when things don't have to be processed immediately, but have to be processed
in First In First Out order like Breadth First Search. This property of Queue makes it also useful
in following kind of scenarios. ... See this for more detailed applications of Queue and Stack

queue::pop() is used to push or delete an existing element from the


beginning or start of the queue container. pop() accepts no
parameter, and deletes the element from the beginning of
the queue associated with the function and reduces the size of
the queue

Purpose of queue:
Queues provide services of operations research where various entities such as data,
objects, persons, or events are stored and held to be processed later. In these contexts,
the queue performs the function of a buffer.

Stack Data Structure;


A stack is a basic data structure that can be logically thought of as a
linear structure represented by a real physical stack or pile, a structure where insertion and
deletion of items takes place at one end called top of the stack.

Linked List and its types:


 linked list is a linear collection of data elements whose order is not given by their physical
placement in memory. Instead, each element points to the next. It is a data structure consisting
of a collection of nodes which together represent a sequence
 Simple Linked List − Item navigation is forward only. Doubly Linked List − Items can be
navigated forward and backward. Circular Linked List − Last item contains link of the first
element as next and the first element has a link to the last element as previous.

 Singly Linked List.
 Doubly Linked List.
 Circular Linked List.

Circular linked list:


Circular Linked List is a variation of Linked list in which the first element points to the last
element and the last element points to the first element. Both Singly Linked List and
Doubly Linked List can be made into a circular linked list

Doubly Linked
is a variation of Linked list in which navigation is possible in both ways, either forward and
backward easily as compared to Single Linked List. Following are the important terms to
understand the concept of doubly linked list. Link − Each link of a linked list can store a data
called an element
Singly linked list. Singly linked lists contain nodes which have a data field as well as
'next' field, which points to the next node in line of nodes. Operations that can be
performed on singly linked lists include insertion, deletion and traversal

String opertaions:

Method Description

capitalize() Converts the first character to upper case

casefold() Converts string into lower case

center() Returns a centered string

count() Returns the number of times a specified value occurs in a string

encode() Returns an encoded version of the string

endswith() Returns true if the string ends with the specified value

expandtabs() Sets the tab size of the string

find() Searches the string for a specified value and returns the position of where

format() Formats specified values in a string


format_map() Formats specified values in a string

index() Searches the string for a specified value and returns the position of where

isalnum() Returns True if all characters in the string are alphanumeric

isalpha() Returns True if all characters in the string are in the alphabet

isdecimal() Returns True if all characters in the string are decimals

isdigit() Returns True if all characters in the string are digits

isidentifier() Returns True if the string is an identifier

islower() Returns True if all characters in the string are lower case

isnumeric() Returns True if all characters in the string are numeric

isprintable() Returns True if all characters in the string are printable


isspace() Returns True if all characters in the string are whitespaces

istitle() Returns True if the string follows the rules of a title

isupper() Returns True if all characters in the string are upper case

join() Joins the elements of an iterable to the end of the string

ljust() Returns a left justified version of the string

lower() Converts a string into lower case

lstrip() Returns a left trim version of the string

maketrans() Returns a translation table to be used in translations

partition() Returns a tuple where the string is parted into three parts

replace() Returns a string where a specified value is replaced with a specified value

rfind() Searches the string for a specified value and returns the last position of wh
rindex() Searches the string for a specified value and returns the last position of wh

rjust() Returns a right justified version of the string

rpartition() Returns a tuple where the string is parted into three parts

rsplit() Splits the string at the specified separator, and returns a list

rstrip() Returns a right trim version of the string

split() Splits the string at the specified separator, and returns a list

splitlines() Splits the string at line breaks and returns a list

startswith() Returns true if the string starts with the specified value

strip() Returns a trimmed version of the string

swapcase() Swaps cases, lower case becomes upper case and vice versa

title() Converts the first character of each word to upper case


translate() Returns a translated string

upper() Converts a string into upper case

zfill() Fills the string with a specified number of 0 values at the beginning

Prefix to Postfix
Prefix expression notation requires that all operators precede the two operands that
they work on. Postfix, on the other hand, requires that its operators come after the
corresponding operands

A tree data structure


can be defined recursively as a collection of nodes (starting at a root node), where each
node is a data structure consisting of a value, together with a list of references to nodes
(the "children"), with the constraints that no reference is duplicated, and none points to
the root

Types;

 AA tree.
 AVL tree.
 Binary search tree.
 Binary tree.
 Cartesian tree.
 Conc-tree list.
 Left-child right-sibling binary tree.
 Order statistic tree

AvL:
an AVL tree is a self-balancing binary search tree. It was the first such data structure to be
invented. In an AVL tree, the heights of the two child subtrees of any node differ by at most
one; if at any time they differ by more than one, rebalancing is done to restore this property
AA trees 

are the variation of the red-black trees, a form of binary search tree. AA


trees use the concept of levels to aid in balancing binary trees. The level of
node (instead of colour) is used for balancing information. ... The level of
black nodes are one less than the level of their parent node
A Binary Search Tree
 (BST) is a tree in which all the nodes follow the below-mentioned
properties − The value of the key of the left sub-tree is less than the value
of its parent (root) node's key. The value of the key of the right sub-tree is
greater than or equal to the value of its parent (root) node's key

In computer science, a binary tree is a tree data structure in which each


node has at most two children, which are referred to as the left child and
the right child.

In-order Traversal
In this traversal method, the left subtree is visited first, then the root
and later the right sub-tree. We should always remember that every
node may represent a subtree itself.
If a binary tree is traversed in-order, the output will produce sorted
key values in an ascending order

Pre-order Traversal
In this traversal method, the root node is visited first, then the left
subtree and finally the right subtree
Post-order Traversal
In this traversal method, the root node is visited last, hence the name. First
we traverse the left subtree, then the right subtree and finally the root
node.

A graph 
is a common data structure that consists of a finite set of nodes (or
vertices) and a set of edges connecting them. A pair (x,y) is referred to as
an edge, which communicates that the x vertex connects to the y vertex. In
the examples below, circles represent vertices, while lines represent edges
For example, a single user in Facebook can be represented as a node (vertex) while their
connection with others can be represented as an edge between nodes. Each node can be
a structure that contains information like user's id, name, gender, etc

Why we use graph:


Graphs are a powerful and versatile data structure that easily allow you to represent real life
relationships between different types of data (nodes). ... The edges (connections) which
connect the nodes i.e. the lines between the numbers in the image

Why we use graph in data structure?


A graph is a non-linear data structure, which consists of vertices(or nodes) connected
by edges(or arcs) where edges may be directed or undirected. In Computer
science graphs are used to represent the flow of computation

Adjacent:
In a graph, two vertices are said to be adjacent, if there is an edge
between the two vertices. Here, the adjacency of vertices is
maintained by the single edge that is connecting those two vertices.
In a graph, two edges are said to be adjacent, if there is a common
vertex between the two edges
Graph searches and Graph Algorithms
A graph search is an algorithm scheme that visits vertices or vertices and edges in
a graph, in an order based on the connectivity of the graph. ... In a graph search, edges
are visited at most once and not all edges are visited

Dijkstra's algorithm,
published in 1959, is named after its discoverer Edsger Dijkstra, who was a Dutch
computer scientist. This algorithm aims to find the shortest-path in a directed or
undirected graph with non-negative edge weights. ... Connected graph: A path exists
between each pair of vertices in this type of graph

You might also like