×

# EXPCODE1 - Editorial

 1 PROBLEM LINK-https://www.codechef.com/problems/EXPCODE1 DIFFICULTY:EASY PREREQUISITES:Array,Sorting PROBLEM:Being a programmer, Chef like arrays lot. On Chef' birthday,Chef friends given him an array "a" consists of n distinct integers. Unfortunately, the size of array "a" is too small. Chef want a bigger array!,Chef friends agree to give him an bigger array. but only if Chef is able to answer the following questions correctly: 1-Largest element in array a 2-Kth largest element Help him for getting bigger Array! EXPLANATION:First We need Largest Element in the Array,so we have to Sort the Array,you can use any sorting technique(bubble sort,quick sort,etc) because there is no issue of Constraints and then print the largest element in array a[ n-1 ],Then answer for 2nd Question is print a[n-k],because we know the kth largest element is at position n-k Algorithm: begin BubbleSort(list) for all elements of list  if list[i] greater list[i+1] swap(list[i], list[i+1]) end if end for  return list end BubbleSort Implementation: https://goo.gl/oKM4kb AUTHOR'S AND TESTER'S SOLUTIONS:http://campus.codechef.com/EXCO17TS/viewsolution/13037182/ Edit1-Link+Corrections asked 15 Mar '17, 13:17 1★vivek96 518●2●20 accept rate: 7% 0★admin ♦♦ 19.7k●350●498●541

 0 Hey dear, please try to fix the following- 1 . Both the links, problem and author, lead to your profile. Also, you are not "author" of problem, but "editorialist". Its best to follow usual convention to avoid unnecessary hassle. (I know that by author you meant author of editorial , but still.) 2 . Its a beginner problem, and I am sure that beginners would appreciate if you can shed some more light on sorting techniques. Because its unfair that we expect beginners to already know advanced sorting techniques like quick sort, merge sort etc. What I want to convey is that, editorial should have something/some concept for people to learn, apart from the solution. If you can include details of one of the sorting techniques, the editorial would get a lot attractive to beginners. 3 . Stray link in line "array--a[n-1],Then answer for 2nd Question " (last line of explanation). Fix it by adding a space between square brackets and n-1. 4 . An analysis of time complexity is generally expected in editorials. See if you can do something about it :) answered 15 Mar '17, 13:57 15.2k●1●18●59 accept rate: 18% done,thanks for ur suggestions,pls upvote the question if u like (15 Mar '17, 14:13) vivek961★
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×15,482
×3,705
×836
×775
×7

question asked: 15 Mar '17, 13:17

question was seen: 393 times

last updated: 20 Mar '17, 12:33