• Status: Solved
• Priority: Medium
• Security: Public
• Views: 139

# java data structure regarding list

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
mithunda5011
• 3
• 2
1 Solution

Commented:
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 Commented:
+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

Commented:
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 Commented:
run time complexity....how to determine this one?
0

Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.