Download presentation

Presentation is loading. Please wait.

Published byRoxana Bryer Modified over 3 years ago

1
**Apoorva Vadi M.S Information Systems New York University**

Gyan from the Geek Apoorva Vadi M.S Information Systems New York University

3
**What is computer Science?**

4
**Lets talk about M&M? The Math Monster**

5
BAD MATH !!!!

7
Algorithms… What are those things?

8
**An algorithm…is like a recipe**

Problem solving as an analogy to cooking: 1. Inputs 2. Recipe/Set of defined rules (or an Algorithm) 3. Outputs

9
**Now lets use algorithms…**

To solve Puzzles! Towers of Hanoi Dining Philosophers Travelling salesman Eight queens

10
Towers of Hanoi You have a stack of discs, from largest to smallest, that slide on to the first peg of a three peg board. Your goal is to move the entire stack of discs from the first peg to the third peg. However, you can only move the topmost disc of any peg, and smaller discs must always be placed on larger discs. How many moves will it take?

12
**Now lets write a recipe for this…**

Alternating between the smallest and the next-smallest disks, follow the steps for the appropriate case: For an even number of disks: make the legal move between pegs A and B make the legal move between pegs A and C make the legal move between pegs B and C repeat until complete For an odd number of disks: In each case, a total of 2n-1 moves are made.

13
**But that was too long… lets try recursion…**

Step 1: Move N−1 discs from A to B. This leaves Nth disc alone on peg A. Step 2: Move Nth disc from A to C Step 3: Move N−1 discs from B to C so they sit on disc N.

14
**Dining Philosophers Problem**

Lets try something ‘non-arkymalarky’: Five philosophers sit around a circular table. In front of each philosopher is a large plate of rice. The philosophers alternate their time between eating and thinking. There is one chopstick between each philosopher, to their immediate right and left. In order to eat, a given philosopher needs to use both chopsticks. How can you ensure all the philosophers can eat reliably without starving to death?

15
**So this is a classic example of a common computing problem in concurrency…**

Issues: Deadlock - cycle of unwarranted requests. Every philosopher picked up a left fork and waits for a right fork (forever). Resource Starvation – one philosopher might have to wait extended amounts of time. Mutual exclusion – multiple processes accessing sets of data.

17
**Welcome to the world of Data Structures**

Stacks Queues Linked Lists Trees Have Fun

18
**Applications of Stacks**

Direct applications Page-visited history in a Web brows Undo sequence in a text editor Indirect applications Component of other data structures

19
**Applications of Queues**

Direct application Waiting lines Access to shared resources (e.g., printer) Multiprogramming Indirect applications Component of other data structures

20
**List A singly linked list is a concrete data structure**

consisting of a sequence of nodes -Each node stores element -link to the next node

21
**Queue with a Singly Linked List**

We can implement a queue with a singly linked list -The front element is stored at the first node -The rear element is stored at the last node

22
Doubly Linked List A doubly linked list provides a natural implementation of the List ADT Nodes implement Position and store: -element -link to the previous node -link to the next node Special trailer and header nodes

23
Doubly Linked List

24
Trees In computer science, a tree is an abstract model of a hierarchical structure -A tree consists of nodes with a parent-child relation Applications: -Organization charts -File systems -Programming environments

25
**Binary Trees A binary tree is a tree with the following properties:**

-Each internal node has two children -The children of a node are an ordered pair - We call the children of an internal node left child and right child - Alternative recursive definition: a binary tree is either -a tree consisting of a single node, or - a tree whose root has an ordered pair of children, each of which is a binary tree Applications: -arithmetic expressions -decision processes -searching

26
Binary Tree

27
**Tree Traversals (power of recursion)**

Depth First Search Pre-order(NLR): Root Node- Left child- Right child A-B-D-E-H-I-C-F-G In-order(LNR): Left child - Root Node - Right child D-B-H-E-I-A-F-C-G Post-order(LRN): Left child - Right child – Root Node D-H-I-E-B-F-G-C-A Breadth First Traversal Level order Traversal: Traverse each node level by level A-B-C-D-E-F-G-H-I

28
**Links http://www.youtube.com/watch?v=jq_EcstLlfE&feature=related**

29
That’s all folks !

Similar presentations

OK

ITEC200 – Week08 Trees. www.ics.mq.edu.au/ppdp 2 Chapter Objectives Students can: Describe the Tree abstract data type and use tree terminology such as.

ITEC200 – Week08 Trees. www.ics.mq.edu.au/ppdp 2 Chapter Objectives Students can: Describe the Tree abstract data type and use tree terminology such as.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on two point perspective photography Ppt on history of olympics Ppt on limitation act 1939 Ppt on eisenmenger syndrome life Ppt on do's and don'ts of group discussion videos Ppt on origin of numbers Ppt on carry select adder Ppt on mass media in india Ppt on business cycle phases in order Ppt on network marketing