View stunning SlideShares in full-screen with the new iOS app!Introducing SlideShare for AndroidExplore all your favorite topics in the SlideShare appGet the SlideShare app to Save for Later — even offline
View stunning SlideShares in full-screen with the new Android app!View stunning SlideShares in full-screen with the new iOS app!
1.
Description: A brief introduction to Data Structure and AlgorithmsDuration: 90 minutesStarts at: Saturday 4th May 2013, 07:00PM-by Dharmendra Prasad1
2.
Table of Contents1. What is a Data Structure2. Need of a Data Structure3. Basic Features of a Data Structure4. Some Basic Examples (Arrays, Linked Lists, Trees, Graphs,Stack, Queues)5. Design Considerations6. Adapting data structures to solve real world problems.7. A brief Introduction to Algorithms2
3.
What is a data structure?A data structure is a blue print which defines how a data set can beorganized.It can be as simple as a data structure which stores the co-ordinates of a point on a co-ordinate plane or an array ofnumbers/objects.It can also be as complex as a Red-Black Tree or a connected cyclicgraph used by LinkedIn to store user profiles and theirconnections.3
4.
Why do we need a data structure?Everything has a purpose and so do data structures.Think of a very simple problem of finding sum of 10 numbers. This can be solved byseveral ways as below:1. Input one number at a time and keep it adding to the sum and return the sum.2. Input an array of 10 numbers, iterate through the array, keep adding into sum andreturn the sum.3. Input 10 numbers in a linked list, iterate through the list, add it to the sum and returnthe sum.There might be many more ways, what the point is it is more practical when we can use adata structure to solve this problem statement.4
5.
Basic Features of a Data Structure.Problem Statement: Sort a list of 100000 numbers in ascending order.Put them in an array, iterate through the array, compare the adjacentnumbers and swap if required. Repeat this process multiple times on thearray till there is no more swaps performed : Bubble SortQuestions:What if accessing the numbers in the array is not as easy as indexedaccess.What if re-arranging the numbers in the array is a tedious task which takesa lot of time.What if putting all the elements in the array is a complex task.Cont…5
6.
This outlines the features of a good data structure:1. It should be easy to build.2. It should facilitate easy inserts, fetch, update and delete.3. It must not consume more than required memory.4. It should be easily extensible.5. It should support generic data types.6. And of course easy to code and understand.6
7.
Examples of some data structures:There are multiple data structures mentioned below: Arrays Maps Linked Lists Stack Queues Trees GraphsNote: They all have their purposes, we cant just use onedata structure in place of the other.7
8.
Design Considerations:As we know data structures are designed for specific purpose.Hence it is important to understand the design consideration.Problem Statement: Storing values against keys and accessing it on afrequent basis and updating it.It is important to find out why we need a data structure for a specific problem.For the above problem:1. Storing values against some identifier.2. Easy access, if possible in access in smallest time.3. Easy updates on the value for a given key.4. Insert need not be very efficient, as our goal is to load it once at the initialsetup.5. Removal need not be very efficient as our purpose is to store, fetch andupate.8
9.
Brief Introduction to Algorithms.Solving a problem must have a well defined set of steps. These steps in theirspecific order is called an algorithm for the given problem.Problem Statement: Find the largest prime number less than 100.Simplest approach:Create an array of prime numbers and store 2.Run a loop from 2 to 100.for each x between 2 to 100for each number in the prime arraycheck if it divides the x.if x is not divisible by any prime number in the arraystore x as the next prime number.9
Views
Actions
Embeds 0
Report content