Solved

java data structure regarding list

Posted on 2007-12-03
5
129 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

773 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