algorithm

Q1) Show, by applying the limit test, that each of the following is true. a) The functions f(n)= n(n-1)/2 and g(n)= n^2 grow asymptotically at equal rate. b) The functions f(n)=log n grow asymptotically at slower rate than g(n)=n. Q2) Show that log (n!) = Θ (nlog n); Q3) Design an algorithm that uses comparisons to select the largest and the second largest of n elements. Find the time complexity of your algroithm (expressed using the big-O notation). Q4) Given an a binary array or list of n elements, where each element is either a 0 or 1, we would like to arrange the elements so that all of those that are equal to 0's appear first followed by all the elements that are equal to 1's. a) Write an algroithm or a function that uses comparisons to arrange the elements as given above. Do not use any extra arrays in your algorithm. b) Find the time, T(n), needed by your algorithm in the worst-case and then express it using the big-O notation. c) Find the time, T(n), needed by your algorithm in the best-case and then express it using the big-Ω notation. d) Find the time, T(n), needed by your algorithm in the average-case and express it using the big-Θ notation.

Related Questions

Abstraction in python...

Abstraction in PythonAbstraction is used to hide the internal functionality of the function from the users.The users only interact with the basic impl...

Lecture notes in pharmacy practice tutor 2021 202...

Lecture Notes in Pharmacy PracticeLecture Notes inPharmacy PracticeEdited byLilian M AzzopardiBPharm(Hons), MPhil, PhD, MRPharmSAssociate Professor an...

Python constructor...

Python ConstructorA constructor is a special type of method (function) which is used to initialize theinstance members of the class.In C++ or Java, th...

Efficient tips to adhere to a healthy diet plan...

Efficient Tips to Adhere to a Healthy Diet PlanA healthy eating habit nourishes your body with the appropriate amount ofnutrients required. Besides, i...

Muhammad Ali1942-2016Early life Born in January 17,1942 Birth place- Louisville U.S Birth name-Cassius Clay Accepted Islam in 1964 Renamed-Muhammad Al...

Benefits of a nutrition consultations...

Benefits of a Nutrition ConsultationsWhen it arrives to getting through a long and tiring workday, the type ofnutrition intake you bring in plays an i...

Python class and objects...

Python Class and ObjectsWe have already discussed in previous tutorial, a class is a virtual entity and can beseen as a blueprint of an object. The cl...

A guide for plant based meal vegan meal delivery...

A guide for Plant-Based Meal & Vegan Meal Delivery ServiceAre you planning to switch your diet plan? If yes, you may consider plantbased forward (diet...

Electric charges and fields...

a.ELECTROSTATICS: ELECTRIC CHARGES AND FIELDElectrostatics is the study of charges at rest.Charge (q)-Charge is an intrinsic property of matter due to...

Vegan diet plan health benefits foods and tips...

Vegan diet plan: Health benefits, foods, and tipsThere are numerous reasons to opt for vegan meals and plant-based dietplans. Choosing the right plant...

The best iron rich vegan foods...

The best iron-rich vegan foodsBeing the mineral essential, iron promotes proper development andgrowth. To make certain hormones and hemoglobin, your b...

Python oops concepts...

Python OOPs ConceptsLike other general-purpose programming languages, Python is also an object-orientedlanguage since its beginning. It allows us to d...

Scientific benefits of following a plant based di...

Scientific Benefits of Following a Plant-Based DietIntroducing yourself to a plant-based diet doesn't mean you are giving upthe chance to dive int...

Purple sprout...

If you want to eat more Plant-Based Meal, it can be hard forbusy people to have fresh produce on hand to eat and cook.Thats what Purple Sprout is all...

Purple sprout 1...

Start on a Delicious Journey toHealthPURPLE SPROUTV EG A N MEA L, D ESSERT S, A N D MO R EThe most convenient anddelicious way to achieve yourhealth o...

Current electricity...

"'CURRENT ELECTRICITYD'Electric current (I)" Current is defined as the rate of flow of charge |Scalar quantity | SI Unit- ampere (A) Direction...

Today I will be talking about one of the g.o.a.t ( greatest of all time). - The AmericanMuhammad Ali.He was born Cassius Clay and later changed his na...

Plant based nutrition consultations...

Plant Based Nutrition ConsultationsPeople choose to be vegan for many different reasons, especially becausethey hope to reap the full health benefits...

Know the significant favorable circumstances of t...

know the Significant favorable circumstances of the PlantBased FoodHaving a plant-based diet plan is often thought of as the healthiestapproach to eat...

Improve your mood with healthy food...

Improve your mood with healthy foodChallenges and depravity go hand in hand, but when you have your tummyfull, nothing can motivate you to take up the...

Improve your mood with healthy food 1...

Improve your mood with healthy foodChallenges and depravity go hand in hand, but when you have your tummyfull, nothing can motivate you to take up the...

Healthy vegetarian snacks that keep you full...

Healthy Vegetarian Snacks that Keep You FullHealthy snacking improves overall health, curbs cravings, fights weightgain, boosts brainpower, regulates...

Moving charges and magnetism...

tf MOVING CHARGES AND MAGNETISMssOersteds experimentsHans Christian Oersted noticed that a current carrying wire caused a noticeable deflection in a n...

Rate base and percentage study material...

FUNDAMENTALS OF MATHEMATICS- STUDY MATERIAL & NOTES, MAY 2014Objectives1. Find the rate, base and percentage2. Solve problems involving rate, base and...