Solved

java data structure regarding list

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now