Design a time algorithm, Data Structure & Algorithms

Assignment Help:

Q. An, array, A comprises of n unique integers from the range x to y(x and y inclusive where n=y-x). Which means, there is only one member that is not in A. Design an O(n) time algorithm to find that number.       

 

Ans:

The algorithm to find the number that is not array A where n contains n

unique (n = x - y):

find(int A[],n,x,y)

{

int i,missing_num,S[n]; for(i=0, i

{if(S[i] == -999)

{

missing_num = i + x;

break;

}

}

}


Related Discussions:- Design a time algorithm

Circularly linked lists implementation, CIRCULARLY LINKED LISTS IMPLEMENTAT...

CIRCULARLY LINKED LISTS IMPLEMENTATION A linked list wherein the last element points to the first element is called as CIRCULAR linked list. The chains do not specified first o

Elaborate the symbols of abstract data type, Elaborate the symbols of abstr...

Elaborate the symbols of abstract data type length(a)-returns the number of characters in symbol a. capitalize(a)-returns the symbol generated from a by making its first cha

Implement an algorithm to simulate car re-organizing, Design  and implement...

Design  and implement  an algorithm  to simulate car  re-organizing of the train at the railway switching junction. You can only use stacks as the data structure to represent the t

Deletion algorithm for dequeue, Deletion Algorithm for dequeue Step 1:...

Deletion Algorithm for dequeue Step 1: [check for underflow]   If front = 0 and rear = 0   Output "underflow" and return Step 2: [delete element at front end]   If front

2 Flow Charts, 1.Create a flowchart to show the process that will allow the...

1.Create a flowchart to show the process that will allow the implementation of Stack, Push, and Pop operations. 2.Create a flowchart to show the process that will allow the impleme

SORTING ALGORIthm, the deference between insertion,selection and bubble sor...

the deference between insertion,selection and bubble sort

Explain internal and external nodes, Explain Internal and External Nodes ...

Explain Internal and External Nodes  To  draw  the  tree's  extension  by  changing  the  empty  subtrees  by  special nodes. The  extra  nodes shown by little squares are know

Curve, write a c++ program to find out the area of a curve y=f(x) between x...

write a c++ program to find out the area of a curve y=f(x) between x=a and x=b

Array-based representation of a binary tree, Assume a complete binary tree ...

Assume a complete binary tree T with n nodes where each node has an item (value). Label the nodes of the complete binary tree T from top to bottom & from left to right 0, 1, ..., n

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd