My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Reply
 
LinkBack Thread Tools Display Modes
January 6th, 2019, 08:07 AM   #1
Member
 
Joined: Oct 2017
From: Rumba

Posts: 36
Thanks: 0

Algorithms tracing question

http://prntscr.com/m3qhrw

Solution 1
A) 5,7,9,3,9,14
Compare 5 with 7,9,3,9,14 (no match)
Compare 7 with 9,3,9,14 (no match)
Compare 9 with 3,9 (match 9=9) so returns false.


Solution 2
A) array values are
values 5 7 9 3 9 14
i from 0-->4 0 1 2 3 4
j from 1-->5 1 2 3 4 5
when i reaches 3rd loop in uniqueElements1 algorithm it find a[i]==a[j] for i==2 and j==4 and returns false.
so no of iteration =3 for i loop

Which solution is correct and why?
sita is offline  
 
Reply

  My Math Forum > Science Forums > Computer Science

Tags
algorithms, question, tracing



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Big-O question - Algorithms sita Computer Science 6 December 3rd, 2018 05:19 PM
Algorithms question help sita Computer Science 3 November 3rd, 2018 10:36 AM
Algorithms question sita Computer Science 6 November 2nd, 2018 07:57 PM
Difficult question on efficiency and algorithms OriaG Calculus 9 June 8th, 2015 09:13 PM
Tracing a graph jomagam Applied Math 4 October 8th, 2013 02:53 PM





Copyright © 2019 My Math Forum. All rights reserved.