Introductory Concepts Algorithm Constructs Arrays
Introductory Concepts Algorithm Constructs Arrays
Introductory Concepts
Algorithm Constructs
Arrays
• During linking process linker embedds static code Lib file code into exe during exe or dll creation process
• Native Windows inbuilt programs are linked through Relocation Table in EXE which would be loaded at Runtime as
well as invoked.
o A Path of Exeuction
o Owns Stack
Program under exeuction invoke malloc or new function uses Dynamic memory allocation
Other Kernel objects are: Inter process communction (IPC) objects such as Clipboard
Data Strucures are every where in Process, Threads, Stack, Heap, Kernel, even in Device drivers. More you go close to
hardware , you get less memory for execution with finite instruction Sets. So choose correct data structure and efficient
algorithms are important by developer. And good understanding of how code runs in enviornment.
Algorithm
An "algorithm" is a method for doing something, a well-defined set of instructions such as a computer could run. The name
comes from the Persian mathematician Mu?ammad ibn Musa al-Khwarizm, who wrote a book on numerical calculations.
Arrays :
Structures :
Rather, they are programming constructs through which you can build these Data structures.
Most Important Use of a Structure is Gathering of Data Bits which are Similar at one place in the memory
To a Book (Like Name, Author etc) can be placed at one place in memory using a structure
Linked Lists :
They Can Work in most of the places Arrays work. But Difference in usage depends upon two choices we make when we
design a system. Those choices are :
If Total Number of Elements in Array changes often the probably Linked list is better for that application as it is less costly
to add and remove nodes in a Linked List.
Good real examples to show the usage and importance of linkedlist:
• Consider the history section of web browsers, where it creates a linked list of web-pages visited, so that when
you check history (traversal of a list) or press back button, the previous node's data is fetched.
• One common sighted example is low level memory management (i.e. the heap as managed by malloc in C or new
in Java, etc) is often implemented as a linked list, with each node representing a used or available (free) block of
memory.
• These blocks may be of any size, change size (combine and split), be freed or assigned in any order, and reordered.
• A linked list means you can keep track of all of these "nodes" and manipulate them fairly easily. Also, Hashtables
that use chaining to resolve hash collisions typically have one linked list per bucket for the elements in that bucket.
• A simple real-life example is a Train, here each coach is connected to its previous and next coach (Except first and
last).
• In terms of programming consider coach body as node value and connectors as links to previous and next nodes.
• Our brain is also a good example of linked list. In the initial stages of learning something by heart, the natural
process is to link one item to next. It's a subconscious act. Also, when we forget something and try to remember,
than our brain follows association and tries to link one memory with another and so on and we finally recall the
lost memory.
• E.g. Consider the thinking process when you placed your bike key somewhere and couldn't remember.
• Another real life example could a be queue/line of persons standing for food in mess, insertion is done at one end
and deletion at other. And these operations happen frequent.
• Dynamic queues / stacks are efficiently implemented using linked lists.
Tree :
• Have you ever used XML? XML parser uses tree data structure.
• Have you heard of decision tree-based learning? A machine learning algorithm.
• Do you know the domain name server (DNS)? It also uses a tree data structure.
• All software applications in the world somehow, they are using map/hashmap.
• Hashmap has its internal implementation is an AVL tree.
• You know database also uses tree data structure for indexing.
• Are you on any social networking website? You can imagine tree.
Graph :
Good example of graphs is a Map application which will give you shortest path from a point a to point b.
This application may be using nodes to represent different points in the map and applying algorithm to find shortest path.
You can use it to represent a network related routing for analyzing the dynamic connectivity of the path, or users of a social
media app etc.
1.Facebook:
Each user is represented as a vertex and two people are friends when there is an edge between two vertices. Similarly,
friend suggestion also uses graph theory concept.
2.Google Maps:
Various locations are represented as vertices and the roads are represented as edges Graph theory is used to find shortest
path between two nodes.
The “Recommendations for you” section on various e-commerce websites uses graph theory to recommend items of similar
type to user’s choice.
By using traversal algorithms, we can find inding the shortest path between two vertices, and in Travelling Salesmen
Problem, to find connected components in a graph, analysis of networks, to compute maximum flow in a network
Heap :
a Heap can be used any where a priority queue will do the job.
For Example Huffman compression is a classic data compression algorithm that depends upon processing a set of items
with integer weights by combining the two smallest to produce a new one whose weight is the sum of its two constituents.
Sorting :
It a kind of algorithm which will give some order to the set of elements.
sorting has many applications for example Scientific computing is often concerned with accuracy (how close are we to the
true answer?).
Accuracy is extremely important when we are performing millions of computations with estimated values such as the
floating-point representation of real numbers that we commonly use on computers. Some numerical algorithms use priority
queues and sorting to control accuracy in calculations.