•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Computer Science and Software Design section within the Software Development category of DaniWeb, a massive community of 422,676 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,680 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Computer Science and Software Design advertiser: Programming Forums
Views: 372 | Replies: 0
![]() |
•
•
Join Date: Sep 2007
Posts: 12
Reputation:
Rep Power: 2
Solved Threads: 0
input = integer n, array a[1..n]
output = integer w, arrayb[1..w], array c[1..w]
I am confused on how many times the inner while loop and the outer while loop executes how many times? As far as I can do the inner loop goes n(n+1)/2 times and the outer loop goes n times. is this right?? The way I found this solution is by writing this code into Java and prints out a counter on how many times the inner and outer while loop is executed. Though I am not quite sure if this is the right way, so I would like to make sure if you guys could give me a better tips. Thanks guys for all the comments and help.
output = integer w, arrayb[1..w], array c[1..w]
w = 0
while (true){
k = 1;
while (a[k] is equal to nil) do
k++;
if k equals n +1 then halt algorithm
end while
w++;
b[w] = a[k];
c[w] = 1;
a[k] = nil
for j = k+1 through n do
if a[j] and b[w] contain the same value then
c[w] = c[w] + 1;
a[j] = nil
end if
end for
end while Last edited by -EquinoX- : Feb 12th, 2008 at 6:58 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Computer Science and Software Design Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Anagram Tester Program That I Just Can't Figure Out
- Next Thread: software eng.


Linear Mode