讲解:HW5、Java、Benchmarking、JavaProlog|SQL

HW5: Analysis and Benchmarking! 100 ptsDue: Tuesday, November 27th, at 11:59:59 pm Overview 1.In this assignment you will review and analyse the complexity of different algorithms.2.You will execute these algorithms and experience the how the analysis would be applicable to the code you run and benchmark the algorithms.As you get started, please pay attention to the following:●Please read the ENTIRE write-up before getting started.Starter files:●Entry.java ●Helpers.java ●Improve.java ●ImproveTest.java●Search.java ●SearchTest.java ●Sort.java ●SortTest.javaYou will submit the following files for this assignment: ●A report with the run time analysis and the run time plots for the respective algorithms. (You will be using gradescope for this)Where to find the starter code●From ieng6 server at○@ieng6.ucsd.edu:/home/linux/ieng6/cs12f/public/pa5/*Part 1 - Analysis of search algorithms (30 points)The problem of search is one of the most important problems in the field of computer science. Can you imagine a world without Google right now? It takes great effort and algorithmic innovation to provide such search results so fast. In this assignment you will experience how different algorithms affect the time taken to search for objects. How the time taken varies as the number of objects we are searching among varies. How the time taken varies when the cost of different operations vary. And how the theoretical analysis translates to practical effects.In this assignment we have a task of searching through a set of values called ‘Entry’ corresponding to a person’s last name. The entry also contains much more information about the person. For the sake of this assignment that value is just an integer. The task at hand is to find a corresponding entry in a data-structure and return the integer associated with it. THIS HAS ALREADY BEEN IMPLEMENTED. Your task is to analyse and benchmark the algorithms which do this.Q1. There are 3 strategies to to the above task in ‘Search.java’. Go through each of them, analyse and prove the time complexity of each of the provided strategies. Provide answers in Big-O Notation, Omega Notation and Theta Notation wherever applicable. Provide the steps for your analysis. (4pts each)Q2. 1.The function ‘work()’ in represents a constant and the most significant unit of work. In the current problem of search we assume that, this is the comparison to check if the element is the element we want. In order to highlight the significance of the algorithm run_times we have chosen to give a reasonable amount of delay which is representative of it being expensive.2.The file ‘Search’ has a list of Entries in ‘elements’ through which it will search for the corresponding entry. The constructor will also take.a.Work_time - The constant unit of time taken to do a unit of work.b.Hash_time - The constant unit of time taken to run a hash function.c.N - Number of elements to search across.2.The constructor loads the first N entries from a file called ‘data.txt’. Feel free to open and inspect the elements in this.3.You are expected toa.Write test cases in order to check the run time for each strategy. The file ‘SearchTest.java’ has a demo test case showing the use of time commands to inspect the time taken to execute a piece of code. Make use of it as a template to build your own test cases.b.Write test cases to check the time taken by each strategy for N = 10, 20, 50, 100, 200.c.For each of the above N, also vary the work_time between 10, 20, 50.d.For each ot the above cases try with a hash_time of 10, 500.e.As the algorithms performance might vary depending on the elements being searched for, randomly choose 10 different words from the data.txt, Provide the average, maximum and the minimum times among those. (Choose the words wisely and choose different words for each N)NOTE: Please don’t write individual test cases for all of the cases. Make use of loops.4.Plot a graph of total time taken for each of the strategy. With N as the X axis and time taken as the Y axis. Plot 3 graphs, one each (Mean, Minimum, Maximum) with all of the corresponding cases in the same graph. Use colored pen/pencils if you are doing it by hand instead of a software. Label each of the lines according to the configuration that generated the the corresponding entries. Along with the graphs with all the strategies, please attach individual graphs with the 3 strategies for each configuration.(4pts each)A sample graph is as shown below. (The values here are FAKE)NOTE: Do your development work with a lesser work_time and finally run the code with the correct work_time. This will save your time!Graphs needed:Strategy Work_Time Hash_Time TypeAll All All One Each for (Min, Max, Mean)All 20 500 One Each for (Min, Max, Mean)Strategy 1 10, 20, 50 10 One Each for (Min, Max, Mean)Strategy 3, Strategy 2 10, 50 500, 10 One Each for (Min, Max, Mean) Feel free to add any other graphs.Q3. Make some Predictions about what values you would be getting for a particular scenario according to your theoretical analysis. (2pts)Q4. Write about any of the patterns you noticed in your graph. Explain How its coherent with your analysis and prediction. Its ok if its not in sync with your prediction. Write all your interpretations from the graph. (If you notice something completely against your prediction, still write it down and say that it was surprising) (3pts)Q5. Give a comparative statement about which algorithm is the best / most suitable and in what cases. (1pt)Part 2 - Analysis of sort algorithms (30 points)NOTE: Part 2 to is similar to Part 1, but with slight variations. If you are bored of reading and are confident that you could figure out the variations while going through the code, please feel free to skip reading this the following part. HOWEVER DO LOOK AT THE BOLDED PARTS.The problem of sorting is another important problem in the field of computer science. It isHW5留学生作业代做、代写Java程序设计作业、代做Benchmarking作业、代写Java编程作业 代写留学生Pro used as a basic block for many important algorithms. In this assignment you will experience how different algorithms affect the time taken to sort the objects. How the time taken varies as the number of objects we are searching among varies. How the time taken varies when the cost of different operations vary. And how the theoretical analysis translates to practical effects.In this assignment we have a task of searching through a set of values called ‘Entry’ corresponding to a person’s last name. The entry also contains many more information about the person. For the sake of this assignment that value is just an integer. The task at hand is to sort the entries based on the key(Lastname). THIS HAS ALREADY BEEN IMPLEMENTED. Your task is to analyse and benchmark the algorithms which do this.Q1. There are 3 strategies to to the above task in ‘Sort.java’. Go through each of them, analyse and prove the time complexity of each of the provided strategies. Provide answers in Big-O Notation, Omega Notation and Theta Notation wherever applicable. Provide the steps for your analysis. (4pts each)Q2. 3.The function ‘work()’ in represents a constant and the most significant unit of work. In the current problem of search we assume that, this is the comparison to check if the element is the element we want. In order to highlight the significance of the algorithm run_times we have chosen to give a reasonable amount of delay which is representative of it being expensive.4.The file ‘Search’ has a list of Entries in ‘elements’ through which it will search for the corresponding entry. The constructor will also take.a.Work_time - The constant unit of time taken to do a unit of work.b.N - Number of elements to search across.c.Offset - Offset while loading the data.5.The constructor loads the first N entries from a file called ‘data.txt’. You are free to open and inspect the elements in this.6.You are expected toa.Write test cases in order to check the run time for each strategy. The file ‘SortTest.java’ has a demo test case showing the use of time commands to inspect the time taken to execute a piece of code. Make use of it as a template to build your own test cases.b.Write test cases to check the time taken by each strategy for N = 10, 20, 30, 40, 50.c.For each of the above N, also vary the work_time between 1, 2, 5.d.As the algorithms’ performance might vary depending on the elements being sorted. In order to account for this. We will use an offset and load the values from (offset to offset+N) in the file data.txt. To do this In the constructor set the offset value to 0, 200, 400, 600 .. 2000., for, Provide the average, maximum and the minimum times among those. NOTE: Please don’t write individual test cases for all of the cases. Make use of loops.7.Plot a graph of total time taken for each of the strategy. With N as the X axis and time taken as the Y axis. Plot 3 graphs, one each (Mean, Minimum, Maximum) with all of the corresponding cases in the same graph. Use colored pen/pencils if you are doing it by hand instead of a software. Label each of the lines according to the configuration that generated the the corresponding entries. Along with the graphs with all the strategies, please attach individual graphs with the 3 strategies for each configuration. (4pts each)A sample graph is as shown below. (The values here are FAKE)Graphs Needed:Strategy Work_Time TypeAll All One Each for (Min, Max, Mean)All 5 One Each for (Min, Max, Mean)Strategy 1 1, 2, 5 One Each for (Min, Max, Mean)Strategy 3, Strategy 2 1, 5 One Each for (Min, Max, Mean)Feel free to add any other graphs.Q3. Make some Predictions about what value you would be getting for a particular scenario according to your theoretical analysis. (2pts)Q4. Write about any of the patterns you noticed in your graph. Explain How its coherent with your analysis and prediction. Its ok if its not in sync with your prediction. Write all your interpretations from the graph. (If you notice something completely against your prediction, still write it down and say that it was surprising) (3pts)Q5. Give a comparative statement about which algorithm is the best / most suitable and in what cases. (1pt)Part 3 - Analysis of Algorithms (24 points)Q1. Observe the function ‘not_really_a_mystery’ in the file Improve.javaAnalyse the run time complexity of this function. (10pts)Q2. Is this the most efficient way to do the task it is accomplishing? (If the task is still a mystery observe the test case of the task to get a clue). (14 points)If Yes, Explain where the inefficiency arises from. Suggest a better way to do that. Prove that your method is better by analysing it’s complexity and comparing it with the earlier analysis. If No, Argue why the current algorithm cannot be improved.Part 4 - More practice on theory (4x4 = 16 points)Analyse the upper bound of running time (Big-O) in terms of n. Q1.num = 0;for (i = 1; i Num++; Q2.p = 10;num = 0;plimit = 100000;for (i = p; i for (j = 1; j num = num + 1;Q3.for (i = 0; i smallest = i;for (j = i+1; j if (a[j] smallest = j;}swap(a, i, smallest); // has three instructions}Q4.num = 0;i = 0;while (i j = 0;while (j // constant time operationsJ++;}I++;}-------------------------------------------------------------------------------------------------------------------------------Final SubmissionThe final submission for this homework is on November 27, 11:59:59 pm. A report with the answers to the question is to be submitted for the Final Submission. (Please make the graph with all plots big so its easy to look at. Also if you are generating it using a computer. Try to add an additional one with a log scale on the Y axis). This as as courtesy for the graders. It will not affect your grade.Submit via Gradescope. 转自:http://ass.3daixie.com/2018120110863817.html

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,723评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,485评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,998评论 0 344
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,323评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,355评论 5 374
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,079评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,389评论 3 400
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,019评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,519评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,971评论 2 325
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,100评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,738评论 4 324
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,293评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,289评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,517评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,547评论 2 354
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,834评论 2 345

推荐阅读更多精彩内容

  • 最近小米把它的日历单独出来做了个app,非小米用户也能使用,那么为什么计算器这样的东西都可以单独出来呢?看一下界面
    风吹枫落van阅读 577评论 0 0
  • 《离去前》 杨桂晔 浇足喜水花枝,干脆不浇,端给别人照顾 没养小动物,怕建立感情,无宠物可交代 关好液化气,让欠费...
    斑斓月阅读 285评论 0 2
  • 店里最近有人送来一只小狗,说是师院学生毕业后留下的,没人要就送到我们店里,因为听说老板娘想养只小狗。 最开心的是老...
    Air赵胖胖呀阅读 342评论 0 0