Skip to main content

CSC 282.01, Class 02: Common Unix tools

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Questions
  • Detour: A coding challenge
  • Exploring solutions to simple tasks
  • Buffers (optional)

News / Etc.

  • Homework tends to depend on what gets accomplished in class. I’ll email you the homework and reading tonight.
  • Not all of you are associated with the repo yet.
  • Note: We’re using mediocre git approaches in this class. You can commit directly to the master branch of the primary repo. (I enjoy seeing the chaos of file conflicts.)
  • I’m trying a somewhat different approach to today’s class. We’ll see how it goes.
  • Remember to let me know when things seem broken on the Web site.
  • Did my “essay” about buffers make sense or do I need to discuss more?
    • Sam thought he emailed it to you.

Upcoming Work

Forthcoming

Good things to do

  • Events related to recent executive order.
  • Hear from our marketing firm, 11:00 a.m. today in Harris Center Cinema.
  • Hear from analytic support about current projects, 11:30 a.m. today in ARH 302.
  • AppDev is teaching Swiftly this semester. Open to everyone, whether or not you are in AppDev. Contact AM for more info.

Questions

Detour: A coding challenge

The following is presented as close to verbatim as I could make it to ensure accessibility.

Good morning. Welcome to the Microgoogazonbook interview program. As you know, we at Microgoogazonbook need large numbers of SWEs because we chew them up like sunflower seeds. However, we need them to be competent so that they produce useful work before we spit them out. You have indicated that you are “competent” C programmers and that you have taken a reasonable number of undergraduate CS courses. Today we we will begin by checking those claims as part of the interview process.

At Microgoogazonbook, we deal with large amounts of data. It’s therefore important that we have efficient searching procedures. You should all know the binary search procedure.

Suppose we have an array of a trillion items to search. Approximately how many values in that array do we expect binary search to visit? Calls on candidate. Candidates fail spectacularly.

Since we have limited time, we are going to ask you to implement binary search on ordered arrays of integers with no duplicates. No sensible human being would implement binary search on strings in C. The values are ordered smallest to largest.

What do you expect the signature of that procedure to be? Calls on candidate.

int search (int val, int *vals, int n);

Great. We’ll have you return the special value -1 if the value is not found in the array. You can find further details in the repository. You should all know how to use git and Github. Download the project from https://github.com/Grinnell-CSC282/binary-search-2017S and start coding. You may consult each other for help, or even work in pairs. However, you may not Bingle or otherwise search the Web for answers.

You have twenty minutes before I check in.

Go!

Followup

Perhaps we should no longer look for Microgoogazaonbook employees at Grinnell College. I have seen the following unacceptable practices.

  • Commiting cruft to the repo.
  • Putting code in .h files.
  • Commiting non-working code to the repo.
  • Unable to follow instructions. Separate code and check files.
  • Don’t trash the template!

Test

  • Probably checking everything in the sample array (using a for loop).
  • Check for elements not in the array.
    • Probably at different places so that the search method goes in “multiple directions” (down and up or up and down or backwards and frontways).
    • Between every two slots, before smallest, larger than largest
  • Edge case: Empty array.
  • Different sizes of arrays

      for every array size from 0 to 32
        fill position i with 2*i
        for every i from 0 to size-1
          make sure that search(2*i, ...) gives you i
          make sure that search(2*i+1, ...) gives you -1
        make sure that search(-1, ...) gives you -1
    

Going Over Homework

Remove \r characters.

Find all of the misspelled words in a text file

Extract the five highest grades

Extract URLs

Buffers