|
|
- Arline Marshall
- 5 years ago
- Views:
Transcription
1 wwwashekalazizwordpresscom Data Structure Test Paper 3 1(a) Define Data Structure Mention the subject matters of data structure The logical and mathematical model of a particular organization of data is called Data Structure Data structure should be simple enough so that it can easily be processed when necessary and data should bear the relationship with the real world scenario [Source: Seymour Lipschutz] The subject matters of data structure are (i) (ii) (iii) (iv) (v) Various types of data and its physical representation in computer memory Various types of data structures with their logical relationships Various operation of different types of data types Algorithms and techniques for solving problems to get obtain desired result implementing necessary operations on data structures Optimization of time for data processing and memory space requirements (b) Mention the operations of data structure The operations on the data structures are (i) (ii) (iii) (iv) (v) (vi) Insertion: Inserting a new item or data or information into the structure Deletion: Removing an item or data or information from the structure Traversing: If there is collection of data items, then accessing each data item exactly once sometimes called visiting each node or element sequentially Searching: Finding some particular data item or information among the collection of information satisfying specific precondition Sorting: arrangement of data items in specific order like ascending order or descending order of integer contents or names in alphabetical order etc Merging: If there two different list of elements, then both can be combined together to form a new list of elements Here both the list can in sorted order and newly formed combined list should also be in sorted manner We should remember that Sorting and Merging are the operations on data structures in special case [Source: Seymour Lipschutz] (c) What is an algorithm? Explain complexity of an algorithm Page 1 of 7
2 wwwashekalazizwordpresscom The term algorithm comes from or, go and rythm Algorithm is a set of tasks which proceeds sequentially until desired result is obtained or a well defined problem is solved The first algorithm was devised by Abu Musa Al-Zaber Al Kwarizmi to find the result of Greatest Common Division of few integers [Source: Knuth] If we think to find a particular data item in an array using sequential searching ie visiting each element from the beginning and accessing the immediate next element successively until we get out desired element then the time required to find the data item depends on the number of elements in the list sometimes called the size of the data or input size to the searching algorithm If the size is smaller, much time may not be required to catch the desired data object but if the size is large then time will be much more consumed obviously This is called complexity of algorithm We should remember that running time of algorithm and size of the data for operation are two constraints of algorithm complexity and complexity can be expressed as a function of either time or space [Ref: Seymour Lipschutz] Another important fact is that if the desired data item is resided in the very beginning of the list then whatever may be the the size of the list, time requirement is the minimum but if would be in the last element even unavailable then time requirement will be the maximum to finish the traversal These are the best case and worst case respectively But we are generally concerned with the average cases that desired element might be in between the start and end position of the data list and probability to find the item Experts concern about the algorithm modification to optimize the time requirements [Ref: Seymour Lipschutz, Shahani] (d) Explain space time trade-off of algorithms We know that an algorithm is a well defined set of instructions to solve a defined problem Our major concern is to use efficient algorithm Algorithm efficiency depends on two major constraints one is time needed to determine the desired result running the algorithm and another is the memory space required to store and process the data If a computer programmer wants to reduce the time for running the algorithm he can achieve it by increasing the memory space usage On the other hand increasing the time for completing algorithm execution, memory space usage can be reduced This is a matter of optimization This issue is known as time space trade off Example: Let us explain the linear search and binary search first Each data element or particular attribute of each record of a list is compared sequentially from the very beginning of the list towards the last until the desired data or record is not found This is a time consuming process This algorithm requires average time n/2 for n number of records in the list If there are records then times comparisons required on an average On the other hand binary search finds the target in a sorted list dividing the list into two segments almost equally divided and tries to locate the target in one segment where it is possibly located The process is repeated on the targeted segment again dividing segment of the list and this process is further repeated until the desired item is found This process is known as divide and conquer method For records in a list, binary search requires log 2 n = log = 15 times comparisons only This is pretty much time efficient algorithm but the list should be in sorted order Page 2 of 7
3 wwwashekalazizwordpresscom Name Pointer 1 Abbey, Gregory 2 2 Brown, John 4 3 Carey, Mary Davis, Earl 1 5 Ellis, Susan 76 Soc Sec No Name Extra Data Davis, Earl XXXXXXXXX Abbey, Gregory XXXXXXXXX Lane, Alice XXXXXXXXX Brown, John XXXXXXXXX Smith, Mary XXXXXXXXX Auxiliary array sorted alphabetically Main file sorted by social security number We have list of records consists of Social Security Numbers, Names and other extra data If we have to find some one s information in this file searching using social security number using linear search, it will definitely be time consuming That s why a memory space consumption slightly increased by adding a new list or auxiliary array consisting names in alphabetical order ie sorted in ascending order and pointer to locate the same person s information in the main file Now a person can easily be found out using binary search technique in the auxiliary array and more detail information can be found through the pointer in the main file This is a good example of time-space trade off [Source: Seymour Lipschutz] 2(a) Consider the pattern P=aaabb, Construct the table and the corresponding labelled directed graph used in the second pattern matching algorithm Q 0 = Q 1 = a Q 2 = aa Q 3 = aaa Q 4 = aaab Q 5 = aaabb States definition f(, a) = a f(a, a) = aa f(aa, a) = aaa f(aaa, a) = aaa f(aaab, a) = a Page 3 of 7
4 wwwashekalazizwordpresscom f(, b) = f(a, b) = f(aa, b) = f(aaa, b) = aaab f(aaab, b) = aaabb A B Q 0 Q 1 Q 0 Q 1 Q 2 Q 0 Q 2 Q 3 Q 0 Q 3 Q 3 Q 4 Q 4 Q 1 Q 5 State table b a a a a a b b Q 0 Q 1 Q 2 Q 3 Q 4 Q 5 b b State diagram [Source: Seymour Lipschutz] (b) Suppose P and T are strings with lengths R and S, respectively and are stored as arrays with one character per element Write an algorithm to find the index of P in T Algorithm: [Source: Seymour Lipschutz] 1 [Initialize] Set K = 1 and MAX = S R +1 2 Repeat Step 3 to 5 while K MAX 3 Repeat for L = 1 to R [Test each character of P] If P[L] T[K + L 1] then go to Step 5 [End of inner loop] 4 [Success] Set INDEX = K and Exit 5 Set K = K + 1 [End of Step 2 outer loop] 6 [Failure] Set INDEX = 0 7 Exit (c) Let W be the string W= aabcdebecaec (i) INSERT(W, 2, pqrs ); (ii) REPLACE(W, rsb, mnbc ) Page 4 of 7
5 wwwashekalazizwordpresscom (i) (ii) INSERT(W, 2, pqrs ) = apqrsabcdebecaec REPLACE(W, rsb, mnbc ) = aabcdebecaec (d) A text T and pattern P and Q are in memory Write an algorithm which replaces every occurrence of P in T by Q Algorithm: [Source: Seymour Lipschutz] 1 [Find index of P] Set K = INDEX(T, P) 2 Repeat while K 0 (a) [Replace P by Q] Set T = REPLACE(T, P, Q) (b) [Update index] Set K = INDEX(T, P) [End of loop] 3 Write T 4 Exit 3(a) What is array? How linear arrays are represented in memory? An array is a list of data elements of single type either integer or real or character No multiple types of data can be stored in an array An array has fixed size ie the number of elements it can hold is fixed For example, an array is declared with name DATA that consist of N number of integer values First element can be accessed as DATA[1], second as DATA[2] and so on This is a one dimensional array In computer memory, it is represented as follows DATA[1] DATA[2] DATA[3] DATA[3] DATA[N] Page 5 of 7
6 wwwashekalazizwordpresscom (b) What is searching? Write Binary Search algorithm What is the complexity of the Binary search? Searching is the finding the location of a given item among collection of elements Usually data elements are stored in computer memory and we are concerned about finding the location or address of the computer memory where target data item is placed Binary search Algorithm: [Source: Seymour Lipschutz] BINARY(DATA, LB, UB, ITEM, LOC) Here DATA is a sorted array with lower bound LB and upper bound UB, and ITEM is a given item of information The variables BEG, END and MID denote, respectively, the beginning, end and middle location of a segment of elements of DATA This algorithm find the location LOC of ITEM in DATA or sets LOC=NULL 1 [Initialize segment variables] Set BEG=LB, END=UB and MID=INT((BEG+END)/2) 2 Repeat Steps 3 and 4 while BEG END and DATA[MID] ITEM 3 If ITEM < DATA[MID] then Set END=MID-1 Else Set BEG=MID+1 [End of If structure] 4 Set MID=INT((BEG+END)/2) [End of Step 2 loop] 5 If DATA[MID]=ITEM then Set LOC=MID Else Set LOC=NULL [End of If structure] 6 Exit The principle of binary search reduces the size of the searching domain of data collection half in each pass That is why we require at most comparisons f(n) to find the desired item as 2 ( ) > n or equivalently f(n) =< log n + 1 Running time of worst case is approximately equal to log n which is approximately equal to running time of average case For example, if input size is then only 20 comparisons are required to find the required data item 2 > 1000 = Page 6 of 7
7 wwwashekalazizwordpresscom (c) Suppose the following numbers are stored in an array: A=(32, 51, 27, 85, 66, 23, 13, 57) Using Bubble sort algorithm, sort these numbers 32, 51, 27, 85, 66, 23, 13, 57 32, 27, 51, 85, 66, 23, 13, 57 32, 27, 51, 66, 85, 23, 13, 57 32, 27, 51, 66, 23, 85, 13, 57 32, 27, 51, 66, 23, 13, 85, 57 32, 27, 51, 66, 23, 13, 57, 85 32, 27, 51, 66, 23, 13, 57, 85 27, 32, 51, 66, 23, 13, 57, 85 27, 32, 51, 23, 66, 13, 57, 85 27, 32, 51, 23, 13, 66, 57, 85 27, 32, 51, 23, 13, 57, 66, 85 27, 32, 51, 23, 13, 57, 66, 85 27, 32, 23, 51, 13, 57, 66, 85 27, 32, 23, 13, 51, 57, 66, 85 27, 32, 23, 13, 51, 57, 66, 85 27, 23, 32, 13, 51, 57, 66, 85 27, 23, 13, 32, 51, 57, 66, 85 27, 23, 13, 32, 51, 57, 66, 85 23, 27, 13, 32, 51, 57, 66, 85 23, 13, 27, 32, 51, 57, 66, 85 23, 13, 27, 32, 51, 57, 66, 85 13, 23, 27, 32, 51, 57, 66, 85 Page 7 of 7
Data Structures. Chapter 04. 3/10/2016 Md. Golam Moazzam, Dept. of CSE, JU
Data Structures Chapter 04 1 Linear Array A linear array is a list of finite number N of homogeneous data elements such that: The elements of the array are referenced respectively by an index set consisting
More informationDATA STRUCTURES/UNIT 3
UNIT III SORTING AND SEARCHING 9 General Background Exchange sorts Selection and Tree Sorting Insertion Sorts Merge and Radix Sorts Basic Search Techniques Tree Searching General Search Trees- Hashing.
More informationCSE101-lec#19. Array searching and sorting techniques. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming
CSE101-lec#19 Array searching and sorting techniques Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Introduction Linear search Binary search Bubble sort Introduction The process of finding
More informationComputer Science 4U Unit 1. Programming Concepts and Skills Algorithms
Computer Science 4U Unit 1 Programming Concepts and Skills Algorithms Algorithm In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation,
More informationSorting. Introduction. Classification
Sorting Introduction In many applications it is necessary to order give objects as per an attribute. For example, arranging a list of student information in increasing order of their roll numbers or arranging
More informationThe time and space are the two measure for efficiency of an algorithm.
There are basically six operations: 5. Sorting: Arranging the elements of list in an order (either ascending or descending). 6. Merging: combining the two list into one list. Algorithm: The time and space
More informationChapter4: Data Structures. Data: It is a collection of raw facts that has implicit meaning.
Chapter4: s Data: It is a collection of raw facts that has implicit meaning. Data may be single valued like ID, or multi valued like address. Information: It is the processed data having explicit meaning.
More informationSearching, Sorting. Arizona State University 1
Searching, Sorting CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 9 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State
More informationThe Limits of Sorting Divide-and-Conquer Comparison Sorts II
The Limits of Sorting Divide-and-Conquer Comparison Sorts II CS 311 Data Structures and Algorithms Lecture Slides Monday, October 12, 2009 Glenn G. Chappell Department of Computer Science University of
More informationSorting: Overview/Questions
CS121: Sorting and Searching Algorithms John Magee 24 April 2012 1 Sorting: Overview/Questions What is sorting? Why does sorting matter? How is sorting accomplished? Why are there different sorting algorithms?
More informationCSc 110, Spring 2017 Lecture 39: searching
CSc 110, Spring 2017 Lecture 39: searching 1 Sequential search sequential search: Locates a target value in a list (may not be sorted) by examining each element from start to finish. Also known as linear
More informationBinary Search and Worst-Case Analysis
Department of Computer Science and Engineering Chinese University of Hong Kong A significant part of computer science is devoted to understanding the power of the RAM model in solving specific problems.
More informationPERFORMANCE OF VARIOUS SORTING AND SEARCHING ALGORITHMS Aarushi Madan Aarusi Tuteja Bharti
PERFORMANCE OF VARIOUS SORTING AND SEARCHING ALGORITHMS Aarushi Madan Aarusi Tuteja Bharti memory. So for the better performance of an algorithm, time complexity and space complexity has been considered.
More informationLecture 6 Sorting and Searching
Lecture 6 Sorting and Searching Sorting takes an unordered collection and makes it an ordered one. 1 2 3 4 5 6 77 42 35 12 101 5 1 2 3 4 5 6 5 12 35 42 77 101 There are many algorithms for sorting a list
More informationData Structures Lecture 3 Order Notation and Recursion
Data Structures Lecture 3 Order Notation and Recursion 1 Overview The median grade.cpp program from Lecture 2 and background on constructing and using vectors. Algorithm analysis; order notation Recursion
More informationCS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK
CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK Page 1 UNIT I INTRODUCTION 2 marks 1. Why is the need of studying algorithms? From a practical standpoint, a standard set of algorithms from different
More informationQuestion Bank Subject: Advanced Data Structures Class: SE Computer
Question Bank Subject: Advanced Data Structures Class: SE Computer Question1: Write a non recursive pseudo code for post order traversal of binary tree Answer: Pseudo Code: 1. Push root into Stack_One.
More informationAdvanced Algorithms, Third Class, Computer Science Department, CSW,
Done by Mokhtar M. Hasan, Lecturer at the Computer Science Department, College of Science for Women, to fulfill the course subject of Advanced Algorithm material. Advanced Algorithms, Third Class, Computer
More informationSorting Pearson Education, Inc. All rights reserved.
1 19 Sorting 2 19.1 Introduction (Cont.) Sorting data Place data in order Typically ascending or descending Based on one or more sort keys Algorithms Insertion sort Selection sort Merge sort More efficient,
More informationCSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion
CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion Review from Lectures 5 & 6 Arrays and pointers, Pointer arithmetic and dereferencing, Types of memory ( automatic, static,
More informationIntroduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD
Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD In this session, we will write another algorithm to solve a mathematical problem. If you
More informationChapter 10 - Notes Applications of Arrays
Chapter - Notes Applications of Arrays I. List Processing A. Definition: List - A set of values of the same data type. B. Lists and Arrays 1. A convenient way to store a list is in an array, probably a
More information8/5/10 TODAY'S OUTLINE. Recursion COMP 10 EXPLORING COMPUTER SCIENCE. Revisit search and sorting using recursion. Recursion WHAT DOES THIS CODE DO?
8/5/10 TODAY'S OUTLINE Recursion COMP 10 EXPLORING COMPUTER SCIENCE Revisit search and sorting using recursion Binary search Merge sort Lecture 8 Recursion WHAT DOES THIS CODE DO? A function is recursive
More information4.1 COMPUTATIONAL THINKING AND PROBLEM-SOLVING
4.1 COMPUTATIONAL THINKING AND PROBLEM-SOLVING 4.1.2 ALGORITHMS ALGORITHM An Algorithm is a procedure or formula for solving a problem. It is a step-by-step set of operations to be performed. It is almost
More information1 The sorting problem
Lecture 6: Sorting methods - The sorting problem - Insertion sort - Selection sort - Bubble sort 1 The sorting problem Let us consider a set of entities, each entity having a characteristics whose values
More informationSorting Techniques in data Structure Alluvial Zone
International Journal of Research in Advanced Engineering and Technology ISSN: 2455-0876; Impact Factor: RJIF 5.44 www.engineeringresearchjournal.com Volume 2; Issue 3; May 2016; Page No. 61-71 Sorting
More informationBinary Search and Worst-Case Analysis
Yufei Tao ITEE University of Queensland A significant part of computer science is devoted to understanding the power of the RAM model in solving specific problems. Every time we discuss a problem in this
More informationProgramming in OOP/C++
Introduction Lecture 3-2 Programming in OOP/C++ Arrays Part (2) By Assistant Professor Dr. Ali Kattan 1 Arrays Examples Solutions for previous assignments Write a program to enter and store your name and
More informationAn array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store
An array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store either all integers, all floating point numbers, all characters,
More informationLecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays)
Lecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays) In this lecture, you will: Learn about arrays Explore how to declare and manipulate data into arrays Understand the meaning of
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may
More informationChapter 8 Search and Sort
Chapter 8 Search and Sort Goals This chapter begins by showing two algorithms used with arrays: selection sort and binary search. After studying this chapter, you will be able to understand how binary
More informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech
More informationSorted list. Find 104. How many comparisons with sequential search? A. 1 B. 4 C. 11 D. 12 E. 16. Vote at m.socrative.com. Room number
Sorted list 7 8 15 53 54 61 66 75 77 99 104 111 123 124 150 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Find 104. How many comparisons with sequential search? A. 1 B. 4 C. 11 D. 12 E. 16 Vote at m.socrative.com.
More informationFundamental problem in computing science. putting a collection of items in order. Often used as part of another algorithm
cmpt-225 Sorting Sorting Fundamental problem in computing science putting a collection of items in order Often used as part of another algorithm e.g. sort a list, then do many binary searches e.g. looking
More informationCSE 143. Two important problems. Searching and Sorting. Review: Linear Search. Review: Binary Search. Example. How Efficient Is Linear Search?
Searching and Sorting [Chapter 9, pp. 402-432] Two important problems Search: finding something in a set of data Sorting: putting a set of data in order Both very common, very useful operations Both can
More informationDATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305
Q.1 If h is any hashing function and is used to hash n keys in to a table of size m, where n
More informationDefinition: A data structure is a way of organizing data in a computer so that it can be used efficiently.
The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without
More informationlecture notes September 2, How to sort?
.30 lecture notes September 2, 203 How to sort? Lecturer: Michel Goemans The task of sorting. Setup Suppose we have n objects that we need to sort according to some ordering. These could be integers or
More informationOperations on Heap Tree The major operations required to be performed on a heap tree are Insertion, Deletion, and Merging.
Priority Queue, Heap and Heap Sort In this time, we will study Priority queue, heap and heap sort. Heap is a data structure, which permits one to insert elements into a set and also to find the largest
More informationANALYSIS OF ALGORITHMS. ANALYSIS OF ALGORITHMS IB DP Computer science Standard Level ICS3U
C A N A D I A N I N T E R N A T I O N A L S C H O O L O F H O N G K O N G 3.4 3.5 When Things Get Out of Hand data cleanup: shuffle-left proceed through the list from left to right pointing with a finger
More informationDesign and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Week 02 Module 06 Lecture - 14 Merge Sort: Analysis
Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute Week 02 Module 06 Lecture - 14 Merge Sort: Analysis So, we have seen how to use a divide and conquer strategy, we
More informationO(n): printing a list of n items to the screen, looking at each item once.
UNIT IV Sorting: O notation efficiency of sorting bubble sort quick sort selection sort heap sort insertion sort shell sort merge sort radix sort. O NOTATION BIG OH (O) NOTATION Big oh : the function f(n)=o(g(n))
More informationUnit 3 Fill Series, Functions, Sorting
Unit 3 Fill Series, Functions, Sorting Fill enter repetitive values or formulas in an indicated direction Using the Fill command is much faster than using copy and paste you can do entire operation in
More informationUnit 3 Functions Review, Fill Series, Sorting, Merge & Center
Unit 3 Functions Review, Fill Series, Sorting, Merge & Center Function built-in formula that performs simple or complex calculations automatically names a function instead of using operators (+, -, *,
More informationDIVIDE & CONQUER. Problem of size n. Solution to sub problem 1
DIVIDE & CONQUER Definition: Divide & conquer is a general algorithm design strategy with a general plan as follows: 1. DIVIDE: A problem s instance is divided into several smaller instances of the same
More informationC/C++ Programming Lecture 18 Name:
. The following is the textbook's code for a linear search on an unsorted array. //***************************************************************** // The searchlist function performs a linear search
More informationQuestion And Answer.
Q.1 What is the number of swaps required to sort n elements using selection sort, in the worst case? A. Θ(n) B. Θ(n log n) C. Θ(n2) D. Θ(n2 log n) ANSWER : Option A Θ(n) Note that we
More informationAlgorithm Efficiency & Sorting. Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms
Algorithm Efficiency & Sorting Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms Overview Writing programs to solve problem consists of a large number of decisions how to represent
More informationBinary Search to find item in sorted array
Binary Search to find item in sorted array January 15, 2008 QUESTION: Suppose we are given a sorted list A[1..n] (as an array), of n real numbers: A[1] A[2] A[n]. Given a real number x, decide whether
More informationAE52/AC52/AT52 C & Data Structures JUNE 2014
Q.2 a. Write a program to add two numbers using a temporary variable. #include #include int main () int num1, num2; clrscr (); printf( \n Enter the first number : ); scanf ( %d, &num1);
More informationIntroduction to Data Structure
Introduction to Data Structure CONTENTS 1.1 Basic Terminology 1. Elementary data structure organization 2. Classification of data structure 1.2 Operations on data structures 1.3 Different Approaches to
More informationSearching and Sorting
Searching and Sorting Sequential search sequential search: Locates a target value in an array/list by examining each element from start to finish. How many elements will it need to examine? Example: Searching
More informationFINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard
FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we should Use better data structures
More informationECE 122. Engineering Problem Solving Using Java
ECE 122 Engineering Problem Solving Using Java Lecture 27 Linear and Binary Search Overview Problem: How can I efficiently locate data within a data structure Searching for data is a fundamental function
More information7. Tile That Courtyard, Please
7. Tile That Courtyard, Please We shape our buildings; thereafter they shape us. Winston Churchill. Programming constructs and algorithmic paradigms covered in this puzzle: List comprehension basics. Recursive
More informationIntroduction to Linked List: Review. Source:
Introduction to Linked List: Review Source: http://www.geeksforgeeks.org/data-structures/linked-list/ Linked List Fundamental data structures in C Like arrays, linked list is a linear data structure Unlike
More informationPLD Semester Exam Study Guide Dec. 2018
Covers material from Chapters 1-8. Semester Exam will be built from these questions and answers, though they will be re-ordered and re-numbered and possibly worded slightly differently than on this study
More informationCSE 530A. B+ Trees. Washington University Fall 2013
CSE 530A B+ Trees Washington University Fall 2013 B Trees A B tree is an ordered (non-binary) tree where the internal nodes can have a varying number of child nodes (within some range) B Trees When a key
More informationAlgorithm Analysis. This is based on Chapter 4 of the text.
Algorithm Analysis This is based on Chapter 4 of the text. John and Mary have each developed new sorting algorithms. They are arguing over whose algorithm is better. John says "Mine runs in 0.5 seconds."
More informationAlgorithm Analysis. Algorithm Analysis 1
Algorithm Analysis 1 Algorithm Analysis Example: Sequential Search. Given an array of n elements, determine if a given number val is in the array. If so, set loc to be the index of the first occurrence
More informationCOMP3121/3821/9101/ s1 Assignment 1
Sample solutions to assignment 1 1. (a) Describe an O(n log n) algorithm (in the sense of the worst case performance) that, given an array S of n integers and another integer x, determines whether or not
More informationIterative Searching and Sorting
B B Chapter 1 Iterative Searching and Sorting Probably the most important algorithms in all of computer science are the searching and sorting algorithms. They are important because they are so common.
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 10: Search and Heaps MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Search and Heaps 2 Linear Search Binary Search Introduction to trees Priority Queues Heaps Linear Search
More information8.1. Chapter 8: Introduction to Search Algorithms. Linear Search. Linear Search. Linear Search - Example 8/23/2014. Introduction to Search Algorithms
Chapter 8: Searching and Sorting Arrays 8.1 Introduction to Search Algorithms Introduction to Search Algorithms Search: locate an item in a list of information Two algorithms we will examine: Linear search
More informationCSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1
CSE 2100 Data Structures and Introduction to Algorithms...! In Java!! Instructor: Fei Wang! Mid-Term Exam CSE2100 DS & Algorithms 1 1. True or False (20%=2%x10)! (1) O(n) is O(n^2) (2) The height h of
More informationPrepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon
Data Structures &Al Algorithms Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon What is Data Structure Data Structure is a logical relationship existing between individual elements
More information(Refer Slide Time: 01.26)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture # 22 Why Sorting? Today we are going to be looking at sorting.
More informationSorting L7.2 Recall linear search for an element in an array, which is O(n). The divide-and-conquer technique of binary search divides the array in ha
Lecture Notes on Sorting 15-122: Principles of Imperative Computation Frank Pfenning Lecture 7 February 1, 2011 1 Introduction We have seen in the last lecture that sorted arrays drastically reduce the
More informationCS301 - Data Structures Glossary By
CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm
More informationCS 261: Data Structures. Sorted Dynamic Array Bag and Set
CS 261: Data Structures Sorted Dynamic Array Bag and Set 1 Ordered Collections How do we organize data in dictionaries or phonebooks? Find in a phonebook: the phone number of John Smith the person with
More informationPseudo code of algorithms are to be read by.
Cs502 Quiz No1 Complete Solved File Pseudo code of algorithms are to be read by. People RAM Computer Compiler Approach of solving geometric problems by sweeping a line across the plane is called sweep.
More informationIndicate the answer choice that best completes the statement or answers the question. Enter the appropriate word(s) to complete the statement.
1. C#, C++, C, and Java use the symbol as the logical OR operator. a. $ b. % c. ^ d. 2. errors are relatively easy to locate and correct because the compiler or interpreter you use highlights every error.
More informationAlgorithm for siftdown(int currentposition) while true (infinite loop) do if the currentposition has NO children then return
0. How would we write the BinaryHeap siftdown function recursively? [0] 6 [1] [] 15 10 Name: template class BinaryHeap { private: int maxsize; int numitems; T * heap;... [3] [4] [5] [6] 114 0
More informationCSCI 136 Data Structures & Advanced Programming. Lecture 12 Fall 2018 Profs Bill & Jon
CSCI 136 Data Structures & Advanced Programming Lecture 12 Fall 2018 Profs Bill & Jon Last Time Assertions SLL Improvements Tail pointers Circularly Linked Lists Doubly Linked Lists Practice with recursion
More informationCMPSCI 187: Programming With Data Structures. Lecture 5: Analysis of Algorithms Overview 16 September 2011
CMPSCI 187: Programming With Data Structures Lecture 5: Analysis of Algorithms Overview 16 September 2011 Analysis of Algorithms Overview What is Analysis of Algorithms? L&C s Dishwashing Example Being
More informationSorting and Searching
Sorting and Searching Sorting o Simple: Selection Sort and Insertion Sort o Efficient: Quick Sort and Merge Sort Searching o Linear o Binary Reading for this lecture: http://introcs.cs.princeton.edu/python/42sort/
More informationComponent 02. Algorithms and programming. Sorting Algorithms and Searching Algorithms. Matthew Robinson
Component 02 Algorithms and programming Sorting Algorithms and Searching Algorithms 1 BUBBLE SORT Bubble sort is a brute force and iterative sorting algorithm where each adjacent item in the array is compared.
More information6. Algorithm Design Techniques
6. Algorithm Design Techniques 6. Algorithm Design Techniques 6.1 Greedy algorithms 6.2 Divide and conquer 6.3 Dynamic Programming 6.4 Randomized Algorithms 6.5 Backtracking Algorithms Malek Mouhoub, CS340
More informationAnalysis of Algorithms
ITP21 - Foundations of IT 1 Analysis of Algorithms Analysis of algorithms Analysis of algorithms is concerned with quantifying the efficiency of algorithms. The analysis may consider a variety of situations:
More informationUnit 6 Chapter 15 EXAMPLES OF COMPLEXITY CALCULATION
DESIGN AND ANALYSIS OF ALGORITHMS Unit 6 Chapter 15 EXAMPLES OF COMPLEXITY CALCULATION http://milanvachhani.blogspot.in EXAMPLES FROM THE SORTING WORLD Sorting provides a good set of examples for analyzing
More informationString Matching. Pedro Ribeiro 2016/2017 DCC/FCUP. Pedro Ribeiro (DCC/FCUP) String Matching 2016/ / 42
String Matching Pedro Ribeiro DCC/FCUP 2016/2017 Pedro Ribeiro (DCC/FCUP) String Matching 2016/2017 1 / 42 On this lecture The String Matching Problem Naive Algorithm Deterministic Finite Automata Knuth-Morris-Pratt
More informationAbout this exam review
Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review
More informationOutline. What s wrong with Enumerations? Indexing Searching Self-Organizing Vectors Binary Searching Sorting Command line Arguments.
Outline What s wrong with Enumerations? Indexing Searching Self-Organizing Vectors Binary Searching Sorting Command line Arguments 1 What s wrong with Enumerations? Nothing is wrong with them, but they
More informationAlgorithm Analysis and Design
Algorithm Analysis and Design Dr. Truong Tuan Anh Faculty of Computer Science and Engineering Ho Chi Minh City University of Technology VNU- Ho Chi Minh City 1 References [1] Cormen, T. H., Leiserson,
More informationOutline. 14. Organization. Programming in Java. Computer Science Dept Va Tech August D Barnette, B Keller & P Schoenhoff
Outline What s wrong with Enumerations? Indexing Searching Self-Organizing Vectors Binary Searching Sorting Arrays Command line Arguments Indexing Strings 1 What s wrong with Enumerations? Nothing is wrong
More informationSorting. Riley Porter. CSE373: Data Structures & Algorithms 1
Sorting Riley Porter 1 Introduction to Sorting Why study sorting? Good algorithm practice! Different sorting algorithms have different trade-offs No single best sort for all scenarios Knowing one way to
More informationMerge Sort. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong
Department of Computer Science and Engineering Chinese University of Hong Kong In this lecture, we will design the merge sort which sorts n elements in O(n log n) time. The algorithm illustrates a technique
More informationMPATE-GE 2618: C Programming for Music Technology. Unit 4.2
MPATE-GE 2618: C Programming for Music Technology Unit 4.2 Quiz 1 results (out of 25) Mean: 19.9, (standard deviation = 3.9) Equivalent to 79.1% (SD = 15.6) Median: 21.5 High score: 24 Low score: 13 Pointer
More informationMultiway searching. In the worst case of searching a complete binary search tree, we can make log(n) page faults Everyone knows what a page fault is?
Multiway searching What do we do if the volume of data to be searched is too large to fit into main memory Search tree is stored on disk pages, and the pages required as comparisons proceed may not be
More information(Refer Slide Time: 00:50)
Programming, Data Structures and Algorithms Prof. N.S. Narayanaswamy Department of Computer Science and Engineering Indian Institute of Technology Madras Module - 03 Lecture 30 Searching Unordered linear
More informationBinary Trees
Binary Trees 4-7-2005 Opening Discussion What did we talk about last class? Do you have any code to show? Do you have any questions about the assignment? What is a Tree? You are all familiar with what
More informationComputer Programming C++ (wg) CCOs
Computer Programming C++ (wg) CCOs I. The student will analyze the different systems, and languages of the computer. (SM 1.4, 3.1, 3.4, 3.6) II. The student will write, compile, link and run a simple C++
More informationLecture 6 Binary Search
Lecture 6 Binary Search 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning One of the fundamental and recurring problems in computer science is to find elements in collections, such
More information9/10/12. Outline. Part 5. Computational Complexity (2) Examples. (revisit) Properties of Growth-rate functions(1/3)
Outline Part 5. Computational Complexity (2) Complexity of Algorithms Efficiency of Searching Algorithms Sorting Algorithms and Their Efficiencies CS 200 Algorithms and Data Structures 1 2 (revisit) Properties
More informationAnalysis of Algorithms. Unit 4 - Analysis of well known Algorithms
Analysis of Algorithms Unit 4 - Analysis of well known Algorithms 1 Analysis of well known Algorithms Brute Force Algorithms Greedy Algorithms Divide and Conquer Algorithms Decrease and Conquer Algorithms
More informationput your answers to b and c in human-oriented terms.
2. A. A person object has a social security number, a name, and a phone number. Give a complete C++ implementation of quicksort or mergesort that will sort an array of N pointers to person objects so that
More informationSorting. Bringing Order to the World
Lecture 10 Sorting Bringing Order to the World Lecture Outline Iterative sorting algorithms (comparison based) Selection Sort Bubble Sort Insertion Sort Recursive sorting algorithms (comparison based)
More informationCS Sorting Terms & Definitions. Comparing Sorting Algorithms. Bubble Sort. Bubble Sort: Graphical Trace
CS 704 Introduction to Data Structures and Software Engineering Sorting Terms & Definitions Internal sorts holds all data in RAM External sorts use Files Ascending : Low to High Descending : High to Low
More informationSorting. CSE 143 Java. Insert for a Sorted List. Insertion Sort. Insertion Sort As A Card Game Operation. CSE143 Au
CSE 43 Java Sorting Reading: Ch. 3 & Sec. 7.3 Sorting Binary search is a huge speedup over sequential search But requires the list be sorted Slight Problem: How do we get a sorted list? Maintain the list
More information