Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Following are two functions to find the largest of the 4 given numbers. Which of these has better time complexity? Justify your answer. (5 Marks)

Following are two functions to find the largest of the 4 given numbers. Which of these has better time complexity? Justify your answer. (5 Marks) int findLargest1(in a, int b, int c, int d) { int lrg = a; if(b>lrg) lrg=b; else if(c>lrg) lrg=c; else if(d>lrg) lrg=d; return lrg; } int findLargest2(in a, int b, int c, int d) { if(a>b) if(a>c) if(a>d) retrun a; else return d; else if(c>d) return c; else return d; else if(b>c) if(b>d) return b; else return d; else if(c>d) return c; else return d; }

image text in transcribed

int findLargesti(in a, int b, int c, int d) { int lrg = a; if (b>lrg) lrg=b; else if (c>lrg) lrg=c; else if (d>lrg) lrg=d; return lrg; } int findLargest2 (in a, int b, int c, int d) { if(a>b) if(a>c) if (a>d) retrun a; else return d; else if(c>d) return c; else return d; else if(b>c) if (b>d) return b; else return d; else if (c>d) return c; else return d; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago