Solved

java data structure regarding list

Posted on 2007-12-03
5
131 Views
Last Modified: 2013-11-23
pls help i m unable to this one with java data structure........

let D denote the domain of two dimensional square arrays +ive int.the same int may be stored in more than 1 element of a 2 D.Given a 2 D a and a +ive int,p,the findElement function is to determine whether or not p is contained in a.
pls derive the worst case run time complexity

thanks
0
Comment
Question by:mithunda5011
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:gatorvip
ID: 20397509
1. what did your TA say?
2. state your question clearly - i don't understand why you need to type stuff like "+ive" when you're asking for help
3. i'm sure you've done some work on this, right? So what is the worst-case scenario?
0
 

Author Comment

by:mithunda5011
ID: 20397649
+ive means positive-->positive integers in this case

it says 2 dimensional square arrays---so we can take-- int [][] a=new int[3][3];

the problem also says that the numbers stored may not be unique....that is duplicate value is possible---5 can come more than one time.

now the problem says a 2 D array is given...suppose it is declared and initialised like this...

int [][] a=new int[][]{{1,2,3},{3,4,5},{1,6,9}};


and now if anyone asks if the array contains a particular number or not then we hv to search through the array using various algorithm.

1)worst case scenario--the element is not present in the array ....like 7 is not there....so we hv to find what is the formula for deriving that case?mathematically?

2)best case scenario--the element that he user wants is the first element in the array....thanks



0
 
LVL 20

Expert Comment

by:gatorvip
ID: 20398064
1)worst case scenario--the element is not present in the array ....like 7 is not there....so we hv to find what is the formula for deriving that case?mathematically?

Yes, of course.

Worst case scenario is that you search through the whole array and you can't find the element. Your array has dimension n x n so you'll be searching through n^2 elements.
0
 

Author Comment

by:mithunda5011
ID: 20404660
run time complexity....how to determine this one?
0
 
LVL 20

Accepted Solution

by:
gatorvip earned 500 total points
ID: 20407162
You need to read up on Big O Notation.

I can't provide you any more information than I already have, since this question seems to be homework.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 236
Java syntax, or is it Selenium 6 37
swing controls 2 21
IBM TS2900 (3572) Tape Autoloader Java? 12 54
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question