...%LJ 2 QRWDWLRQ Big O notation (with a capital letter O, not a zero), also called Landau's symbol, is a symbolism used in complexity theory, computer science, and mathematics to describe the asymptotic behavior of functions. Basically, it tells you how fast a function grows or declines. Landau's symbol comes from the name of the German number theoretician Edmund Landau who invented the notation. The letter O is used because the rate of growth of a function is also called its order. For example, when analyzing some algorithm, one might find that the time (or the number of steps) it takes to complete a problem of size n is given by T(n) = 4 n2 - 2 n + 2. If we ignore constants (which makes sense because those depend on the particular hardware the program is run on) and slower growing terms, we could say "T(n) grows at the order of n2" and write:T(n) = O(n2). In mathematics, it is often important to get a handle on the error term of an approximation. For instance, people will write ex = 1 + x + x2 / 2 + O(x3) for x -> 0 to express the fact that the error is smaller in absolute value than some constant times x3 if x is close enough to 0. For the formal definition, suppose f(x) and g(x) are two functions defined on some subset of the real numbers. We write f(x) = O(g(x)) (or f(x) = O(g(x)) for x -> C such that |f(x)| to be more precise) if and only if there exist constants N and C |g(x)| for all x>N. Intuitively, this means that f does not grow faster...
Words: 2121 - Pages: 9
...Data Structures and Algorithms DSA Annotated Reference with Examples Granville Barne Luca Del Tongo Data Structures and Algorithms: Annotated Reference with Examples First Edition Copyright c Granville Barnett, and Luca Del Tongo 2008. This book is made exclusively available from DotNetSlackers (http://dotnetslackers.com/) the place for .NET articles, and news from some of the leading minds in the software industry. Contents 1 Introduction 1.1 What this book is, and what it isn’t . . . 1.2 Assumed knowledge . . . . . . . . . . . . 1.2.1 Big Oh notation . . . . . . . . . . 1.2.2 Imperative programming language 1.2.3 Object oriented concepts . . . . . 1.3 Pseudocode . . . . . . . . . . . . . . . . . 1.4 Tips for working through the examples . . 1.5 Book outline . . . . . . . . . . . . . . . . 1.6 Testing . . . . . . . . . . . . . . . . . . . 1.7 Where can I get the code? . . . . . . . . . 1.8 Final messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 1 1 3 4 4 6 6 7 7 7 I Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . reverse order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
Words: 23014 - Pages: 93
...DATA STRUCTURES ANALYSIS OF ALGORITHMS Definition:- The method of solving a problem is known as an algorithm.It is a sequence of instructions that act on some input data to produce some output in a finite number of steps. Properties:- a) Input:An algorithm must receive some input data supplied externally. b)Output:An algorithm must produce atleast one output as the result. c)Finiteness:The algorithm must terminate after a finite number of steps. d)Definiteness:The steps to be performed in the algorithm must be clear and unambiguous. e)Effectiveness:One must be able to perform the steps in the algorithm without applying any intelligence. All algorithms basically fall under two broad categories-Iterative and Recursive algorithms. Iterative Algorithms typically use loops and conditional statements. Recursive Algorithms use a divide and Conquer strategy. As per this,the recursive algorithm breaks down a large problem into small pieces and then applies the algorithm to each of these smal pieces. Determining which algorithm is efficient than the other involves analysis of algorithms. While analyzing,time required to execute it determined .’time’ represents the number of operations that are carried out while executing the algorithm. While analyzing iterative algorithms we need to determine how many times the loop is executed. To analyze a recursive algorithm one needs to determine amount of work done for three things: ...
Words: 2466 - Pages: 10
...A Comparison of Solution Procedures for the Flow Shop Scheduling Problem with Late Work Criterion Jacek Błażewicz *) Erwin Pesch 1) Małgorzata Sterna 2) Frank Werner 3) *) Institute of Computing Science, Poznań University of Technology Piotrowo 3A, 60-965 Poznań, Poland phone: +48 (61) 8790 790 fax: +48 (61) 8771 525 blazewic@sol.put.poznan.pl Institute of Information Systems, FB 5 - Faculty of Economics, University of Siegen Hölderlinstrasse 3, 57068 Siegen, Germany pesch@fb5.uni-siegen.de Institute of Computing Science, Poznań University of Technology Piotrowo 3A, 60-965 Poznań, Poland Malgorzata.Sterna@cs.put.poznan.pl Faculty of Mathematics, Otto-von-Guericke-University PSF 4120, 39016 Magdeburg, Germany Frank.Werner@mathematik.uni-magdeburg.de 1) 2) 3) 1 A Comparison of Solution Procedures for the Flow Shop Scheduling Problem with Late Work Criterion Abstract In this paper, we analyze different solution procedures for the two-machine flow shop scheduling problem with a common due date and the weighted late work criterion, i.e. for problem F2 | dj = d | Yw, which is known to be binary NP-hard. In computational experiments, we compare the practical efficiency of a dynamic programming approach, an enumerative method and a heuristic list scheduling procedure. Test results show that each solution method has its advantages and none of them can be rejected from the consideration a priori. Keywords: flow shop, late work, dynamic programming, enumerative...
Words: 9053 - Pages: 37
...Component 01 - Computing Principles | AS-Level (H046) | A-Level (H446) | 1 The characteristics of contemporary processors, input, output and storage devices | Structure and function of the processor | The Arithmetic and Logic Unit (ALU), Control Unit and registers: Program Counter (PC), Accumulator (ACC), Memory Address Register (MAR), Memory Data Register (MDR), Current Instruction Register (CIR).Buses: data, address and control: How this relates to assembly language programs.The fetch-decode-execute cycle, including its effect on registers.The factors affecting the performance of the CPU, clock speed, number of cores, cache.Von Neumann, Harvard and contemporary processor architecture. | The use of pipelining in a processor to improve efficiency. | Types of processor | The differences between, and uses of, CISC and RISC processors.Multicore and parallel systems. | GPUs and their uses (including those not related to graphics). | Input, output and storage | How different input output and storage devices can be applied as a solution of different problems.The uses of magnetic, flash and optical storage devices.RAM and ROM.Virtual storage. | | 2 Software and software development | Operating systems | The need for, function and purpose of operating systems.Memory management (paging, segmentation and virtual memory).Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle.Scheduling: round robin, first come...
Words: 1302 - Pages: 6
...Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved. Brute Force A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples: 1. Computing an (a > 0, n a nonnegative integer) 2. Computing n! Multiplying two matrices 3. 4. Searching for a key of a given value in a list Brute Force Sorting What would be the most straightforward method for solving the sorting problem? Reasonable people may disagree on the answer. Selection Sort or Bubble Sort Brute-Force Sorting Algorithm Selection Sort : Scan the array to find its smallest element and swap it with the first element. Then, starting with the second element, scan the elements to the right of it to find the smallest among them and swap it with the second elements. Generally, on pass i (0 i n-2), find the smallest element in A[i..n-1] and swap it with A[i]: A[0] . . . A[i-1] | A[i], . . . , A[min], . . ., A[n-1] in their final positions Example: 7 3 2 5 Selection Sort : Example 1 ) |89 45 68 90 29 34 17 2 ) 17 | 45 68 90 29 34 89 3 ) 17 29 | 68 90 45 34 89 4 ) 17 29 34 | 90 45 68 89 5 ) 17 29 34 45 | 90 68 89 6 ) 17 29 34 45 68 | 90 89 7 ) 17 29 34 45 68 89 | 90 Analysis of Selection Sort Time efficiency: Space efficiency: Stability: Θ(n^2) Θ(1), so in place yes Bubble Sort Compare adjacent elements of the list and exchange them if they are...
Words: 1552 - Pages: 7
...end; unsigned long long a = 1, b = 1; //prompt start = clock(); //start timer for(unsigned long long n = 3; n <= count; ++n) //calculated by iterative { unsigned long long fib = a + b; a = b; b = fib; if (n==count) cout<<"Fibonacci Number: "<<fib<<endl; } //end timer show Runtime end=clock(); double diff ((double)(end - start)); double time = diff / CLOCKS_PER_SEC; cout<<"Runtime ("<< count <<"th) : "<< time <<" seconds"<<endl; cout<<"------------------------------------------------------"<<endl; count = count *10; } system ("pause"); return 0; } 2. Analysis: n=3count1=count-3+1 T(n) =count-2 =O(count) =O(n) 3. Table n-th Fibonacci no. | Time 1(sec) | Time 2(sec) | Time 3(sec) | Average(sec) | 10 | 0.001 | 0.001 | 0.001 | 0.001 | 100 | 0.001 | 0.001 | 0.001 | 0.001 | 1’000 | 0.002 | 0.001 | 0.001 | 0.0013 | 10’000 | 0.003 | 0.002 | 0.001 | 0.0020 | 100’000 | 0.003 | 0.001 | 0.002 | 0.0020 | 1’000’000 | 0.007 | 0.006 | 0.007 | 0.0067 | 10’000’000 | 0.053 | 0.048 | 0.047 | 0.0493 | 100’000’000 | 0.483 | 0.454 | 0.475 | 0.4706 | 1’000’000’000 | 4.495 | 4.612 | 4.503 | 4.5367 | 10’000’000’000 | 44.401 | 45.114 | 44.984 | 44.833 | 4. Graph b. Recursive Fibonacci 1. Code: #include <iostream> #include <time.h> using...
Words: 4123 - Pages: 17
...LIST OF PRACTICALS OF C++ (CLASS XII) 1. WRITE MENU DRIVEN PROGRAM TO SHOW FOLLOWING OPERATIONS IN A 1-D ARRAY (USING USER DEFINED FUNCTION) MENU 1. CREATION OF AN ARRAY 2. SEARCHING ARRAY USING - 3. LINEAR SEARCH METHOD. BINARY SEARCH METHOD. SORTING ARRAY USING - SELECTION SORT - BUBBLE SORT - INSERTION SORT - MERGE SORT 4. INSERTING AN ELEMENT AT iTH POSITION 6. DELETING AN ELEMENT FROM AN ARRAY 7. 2. MERGE TWO ARRAYS OF INTEGERS IN ASCENDING OR DESCENDING ORDER 5. QUIT WRITE MENU DRIVEN PROGRAM TO SHOW FOLLOWING OPERATIONS IN A 2-D ARRAY (USING USER DEFINED FUNCTION) MENU 1. ADDING TWO 2-D ARRAYS 2. SUBSTRACTING TWO 2-D ARRAYS 3. MULTIPLYING TWO 2-D ARRAYS 4. CHECK WHETHER TWO 2-D ARRAYS ARE EQUIVALENT OR NOT 5. DISPLAY UPPER TRIANGULAR MATRIX 6. DISPLAY LOWER TRIANGULAR MATRIX 7. DISPLAY AND FIND SUM OF DIAGONAL ELEMENTS OF A 2-D ARRAY 8. DISPLAY AND FIND THE ROW-WISE SUM OF A 2-D ARRAY 9. DISPLAY AND FIND THE COLUMN-WISE SUM OF A 2-D ARRAY 10. QUIT 3. USING STRUCTURES WRITE A MENU DRIVEN PROGRAM TO ADD, SUBTRACT AND MULTIPLY AND DIVIDE TWO COMPLEX NUMBERS 4. USING STRUCTURES WAP TO CHECK THE VALIDY OF DATE 5. WRITE A PROGRAM TO DEFINE THE CLASS WORKER SHOWN BELOW CLASS WORKER ( PRIVATE : WNAME CHARACTER (20), WNO INTEGER, WGRATE FLOAT, HOURLYWAGERATE FLOAT, TOTWAGE FLOAT, CALCWAGE(HRWG,WGRATE) PUBLIC...
Words: 944 - Pages: 4
...2010 Fourth Asia International Conference on Mathematical/Analytical Modelling and Computer Simulation Clump Sort: A Stable Alternative To Heap Sort For Sorting Medical Data Visvasuresh Victor Govindaswamy Computer Science Texas A&M University-Texarkana Texarkana, USA lovebat814@yahoo.com Matthew Caudill Computer Science Texas A&M University-Texarkana Texarkana, USA Jeff Wilson Computer Science Texas A&M University-Texarkana Texarkana, USA Daniel Brower Computer Science Texas A&M University-Texarkana Texarkana, USA G. Balasekaran, FACSM Medical and Sports Science Nanyang Technology University Singapore Abstract—Sorting data sets are a thoroughly researched field. Several sorting algorithms have been introduced and these include Bubble, Insertion, Selection, Shell, Quick, Merge and Heap. In this paper, we present a novel sorting algorithm, named Clump Sort, to take advantage of ordered segments already present in medical data sets. It succeeds in sorting the medical data considerably better than all the sorts except when using totally non-clumped data. In this test using totally nonclumped data, Heap sort does only slightly better than Clump sort. However, Clump sort has the advantage of being a stable sort as the original order of equal elements is preserved whereas in Heap sort, it is not since it does not guarantee that equal elements will appear in their original order after sorting. As such, Clump Sort will have considerably better data cache performance...
Words: 1753 - Pages: 8
...INDEX s.no | Name of program | Page no. | Remarks | SORTING PROGRAMS | 1 | program of merge sort | | | 2 | program of quick sort | | | 3 | program of bubble sort | | | 4 | program of insertion sort | | | 5 | program of selection sort | | | SEARCHING PROGRAMS | 6 | program of binary search iterative method | | | 7 | Program of binary search by recursive method | | | MULTIPLICATION PROGRAMS | 8 | program to multiply two matrices using direct method | | | 9 | program to multiply two matrices using recursion | | | 10 | program to multiply two matrices using strassen's method | | | //program of merge sort #include<stdio.h> #include<conio.h> #define MAX 50 void mergeSort(int arr[],int low,int mid,int high); void partition(int arr[],int low,int high); int main() { int merge[MAX],i,n; clrscr(); printf("Enter the total number of elements: "); scanf("%d",&n); printf("Enter the elements which to be sort: "); for(i=0;i<n;i++) { scanf("%d",&merge[i]); } partition(merge,0,n-1); printf("After merge sorting elements are: "); for(i=0;i<n;i++) { printf("%d ",merge[i]); } getch(); } void partition(int arr[],int low,int high) { int mid; if(low<high) { mid=(low+high)/2; partition(arr,low,mid); partition(arr,mid+1,high); mergeSort(arr,low,mid,high); } } void mergeSort(int arr[],int low,int mid,int high) { int i,m,k,l,temp[MAX]; l=low; i=low; m=mid+1; while((l<=mid)&&(m<=high))...
Words: 1948 - Pages: 8
...1. Algorithms A and B perform the same task. On input of size n, algorithm A executes 0.5n2 steps, and algorithm B executes 300n steps. Find the value of n above which algorithm B is more efficient. Show your work. 0.5n2 = 300n => n2 = 600n =>n (n-600) = 0 Thus n = 0 => n – 600 = 0 =>n = 600 To test which one is most effective plug in 601 in both equations A = 0.5(601)2 = 0.5(361201) = 180600.5 B = 300(601) = 180300 Thus B is the most efficient 2. A long, long time ago, when I was in graduate school, I wrote a program to solve a difficult problem. The program had a time complexity of 2n(yeah, no kidding!). On input of size 50, my program finished in about an hour. How long would it have taken me to run my program on input of size 100? If input of 50 takes 1hr in a time complexity of 2n It also takes 1 hour to execute and input of 100 3. Write an All-Pairs algorithm that is given a list of numbers and a target and outputs each pair of values that sum to the target. The two algorithms can work Algorithm 1: 1) Initialize Binary Hash Map M[] = {0, 0, …} 2) Do following for each element A[i] in A[] (a)If M[x - A[i]] is set then print the pair (A[i], x – A[i]) (b)Set M[A[i]] Algorithm 2: 1) Sort the array in non-decreasing order. 2) Initialize two index variables to find the candidate elements in the sorted array. (a) Initialize first to the leftmost index: l = 0 ...
Words: 326 - Pages: 2
...2010 Fourth Asia International Conference on Mathematical/Analytical Modelling and Computer Simulation Clump Sort: A Stable Alternative To Heap Sort For Sorting Medical Data Visvasuresh Victor Govindaswamy Matthew Caudill Jeff Wilson Computer Science Texas A&M University-Texarkana Texarkana, USA lovebat814@yahoo.com Computer Science Texas A&M University-Texarkana Texarkana, USA Computer Science Texas A&M University-Texarkana Texarkana, USA Daniel Brower G. Balasekaran, FACSM Computer Science Texas A&M University-Texarkana Texarkana, USA Medical and Sports Science Nanyang Technology University Singapore Abstract—Sorting data sets are a thoroughly researched field. Several sorting algorithms have been introduced and these include Bubble, Insertion, Selection, Shell, Quick, Merge and Heap. In this paper, we present a novel sorting algorithm, named Clump Sort, to take advantage of ordered segments already present in medical data sets. It succeeds in sorting the medical data considerably better than all the sorts except when using totally non-clumped data. In this test using totally nonclumped data, Heap sort does only slightly better than Clump sort. However, Clump sort has the advantage of being a stable sort as the original order of equal elements is preserved whereas in Heap sort, it is not since it does not guarantee that equal elements will appear in their original order after sorting. As such, Clump Sort will have considerably better data cache performance with both...
Words: 1753 - Pages: 8
...IT 265 Data Structures for Problem Solving Data Structures and Methods 9/20/2014 Phase 5 Contents Executive Summary 4 Phase 1 4 Phase 2 4 Phase 3 4 Phase 4 4 Phase 5 5 Section 1: Lists, Stacks, and Queues 6 Stacks 6 Queues 10 Section 2: Hashing, Heaps and Trees 14 Section 3: Sorting Algorithms 20 Insertion sort 20 Bubble Sort 20 Selection sort 21 Section 4: Searching 22 Array 22 Linked Lists 23 Section 5: Recursion 30 References 33 Executive Summary Phase 1 A list is a collection of items in which the items have a position (Weiss, 2010). A linked list allows data to be input or removed easily because each of the data items in the list is connected to its neighbor by a pointer that can be quickly and easily modified to accommodate new or removed items (CTU M.U.S.E. 2014). The Phase 1 portion of this document will be demonstrating the implementation of Stacks and Queues. Phase 2 Hash tables can be viewed as an array of lists and are used to speed up a search for data by creating a situation that does not require the search to start at the beginning and go through every item. The identifying value is the key and the associated record is the data, thus a hash table is a collection of (key, value) pairs. Phase 3 In order to efficiently use a database, the data must be stored in some sort of order. There are a number of different sorting algorithms; a programmer would choose which one to use depending on the amount...
Words: 3704 - Pages: 15
...set of instructions that , if followed, accomplishes a particular task. 2. What are the characteristics of an algorithm? Input – Zero or more quantities Output – At least one quantity Definiteness – each instruction is clear and unambiguous Finiteness – terminate after a finite number of steps Efficiency – easily understandable 3. Define Space Complexity The Space complexity of an algorithm is the amount of memory it needs to run to completion 4. Define Time Complexity Time complexity of an algorithm is the amount of computer time it needs to run to completion 5. What are asymptotic notations? The notations that enables us to make meaningful statements about the time and space complexity of a program is called asymptotic notations. 6. What are the various asymptotic notations used to define the efficiency of an algorithm? Big ‘Oh’ (O) Omega (Ω) Theta (θ) Little ‘oh’ (o) Little Omega 7. What is information? Information is a recorded or communicated material that has some meaning associated with symbolic representation. 8. What are the aspects to be considered to ensure information transfer between source and destination? Syntactic – Physical form of information Semantic – Meaning Pragmatic – Action taken as a result of interpretation of information 9. State the Markov algorithm It takes the input string X and through a number of steps in the algorithm, transform X to an output string Y 10. Differentiate function & procedure A function is a sub...
Words: 425 - Pages: 2
...example, if we take two 5 bit binary numbers and XOR them, the number of steps taken is 5 and if the same process is repeated for a 100 bit binary number, the number of steps goes up to 100. The algorithm employed in either case is the same; the complexity is given by the size of the numbers. When we say size of a number n, it is defined as the number of binary bits which are required to denote ‘n’ in base 2. For example, 5 in base 10 when expressed in binary takes the form 101, thereby giving n = 3. Similarly 20 is given by 101002 which makes n = 5. Now if we XOR any two numbers each of size n=b, the number of steps taken will be ‘b’. Hence we can say that XORing those numbers has computational complexity of order ‘b’ which is denoted by O(b). This can be applied to even simpler applications like addition wherein if we are to add two n digit numbers, the minimum number of steps taken (ignoring any carry over from the previous step) will be equal to n as we approach from right to left. This can’t be avoided because we need to know every number before we can add them. Coming back to the XOR example stated above, if we are to double the size of the numbers, we will end up doubling the size of the steps required hence increasing the time needed. One important point to take into...
Words: 3078 - Pages: 13