1234u
1234u
An algorithm is a set of commands that must be followed for a computer to perform calculations or other
problem-solving operations.According to its formal definition, an algorithm is a finite set of instructions
carried out in a specific order to perform a particular task.
Advantages of algorithms
The complexity of an algorithm
Describe the quick sort algorithm
Explain how binary search works
What are hash algorithms?
Describe the merge sort algorithm
Explain Dijkstra's shortest path algorithm
Explain the divide-and-conquer technique in algorithms
Explain what is radix sort algorithm
A data structure is a specialized format for organizing, processing, retrieving and storing data. There are
several basic and advanced types of data structures, all designed to arrange data to suit a specific purpose.
Data structures make it easy for users to access and work with the data they need. Most importantly, data
structures frame the organization of information so that machines and humans can better understand it.
Data structures are used to implement the physical forms of abstract data types. Data structures are a crucial
part of designing efficient software. They also play a critical role in algorithm design and how those algorithms
are used within computer programs.
Data types - If data structures are the building blocks of algorithms and computer programs, the primitive -- or
base -- data types are the building blocks of data structures. The typical base data types include the following:
Boolean stores logical values that are either true or false.
Integer stores a range on mathematical integers, or counting numbers. Different sized integers hold a
different range of values. A signed 8-bit integer holds values from -128 to 127, and an unsigned long 32-bit
integer holds values from 0 to 4,294,967,295.
Floating-point numbers store a formulaic representation of real numbers.
Fixed-point numbers are used in some programming languages and hold real values but are managed as
digits to the left and the right of the decimal point.
Character uses symbols from a defined mapping of integer values to symbols.
Pointers are reference values that point to other values.
String is an array of characters followed by a stop code -- usually a "0" value -- or is managed using a
length field that is an integer value.
Types of data structures - The data structure type used in a particular situation is determined by the type of
operations that will be required or the kinds of algorithms that will be applied. The various common data
structures include the following:
Array. An array stores a collection of items at adjoining memory locations. Items that are the same type are
stored together so the position of each element can be calculated or retrieved easily by an index. Arrays
can be fixed or flexible in length.
Stack. A stack stores a collection of items in the linear order that operations are applied. This order could
be last in, first out (LIFO) or first in, first out (FIFO).
Queue. A queue stores a collection of items like a stack. However, the operation order can only be FIFO.
Linked list. A linked list stores a collection of items in a linear order. Each element, or node, in a linked list
contains a data item, as well as a reference, or link, to the next item in the list.
Tree. A tree stores a collection of items in an abstract, hierarchical way. Each node is associated with a key
value, with parent nodes linked to child nodes, or subnodes. There's one root node that is the ancestor of all
the nodes in the tree. Moving down through such a tree structure, from the root node, to access all
subsequent nodes is called traversal and can be done in a variety of orders, some of which can affect the
performance of the tree DSA.
Heap. A heap is a tree-based structure in which each parent node's associated key value is greater than or
equal to the key values of any of its children's key values.
Graph. A graph stores a collection of items in a nonlinear fashion. Graphs are made up of a finite set of
nodes, also known as vertices, and lines that connect them, also known as edges. These are useful for
representing real-world systems such as computer networks.
Trie. A trie, also known as a keyword tree, is a data structure that stores strings as data items that can be
organized in a visual graph.
Hash table. A hash table -- also known as a hash map -- stores a collection of items in an associative array
that plots keys to values. A hash table uses a hash function to convert an index into an array of buckets that
contain the desired data item. Hashing serves up a complexity of its own with a collision – two keys
resulting in the same value, where a new key maps to an already-occupied location in the
table. Chaining resolves this by generating a local linked list to store each of the elements hashed into the
same location.
ARRAYS
An arrangement of objects, pictures, or numbers in columns and rows is called array.
Arrays are useful representation of multiplication concepts. This array has a 4 rows and 3 columns. It can also
be described as a 4 by 3 array. An array is used to store a collection of data, but it is often mode useful to think
of an array as a collection of variables of the same type.
Arrays are used to implement mathematical vectors and matrices, as well as other kinds of rectangular table.
In computer science, the obvious way to store an ordered collection of items is as an array. Array items are
typically stored in a sequence of computer memory locations,but to discuss them, we need a convenient way
to write them down on paper. We can just write the items in order, separated by commas and enclosed by
square brackets.
Thus,
[1,4,17,3,90,79,4,6,81]
a = [1,4,17,3,90,79,4,6,81]