Solved

java data structure regarding list

Posted on 2007-12-03
5
133 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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:

726 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