首页 文章

计算机科学入门任务[关闭]

提问于
浏览
8

今年夏天,我将教授我的第一个大学水平的计算机科学课程,目前我正在努力想出有关学生将完成的有趣作业的想法 . 该课程是该课程的第二个课程,涵盖算法和基本数据结构的分析,如堆栈,队列,列表,树等 .

我有很多想法可以与我一起运行(用马尔可夫链,Twitter客户等创建音乐),但我总是在寻找对学生有趣/有趣的新想法 - 毕竟,最简单的方法是当一个人开心时,成为/继续参与课程材料 . 我正在寻找关于您或其他人过去可能完成的第一年级别任务的想法 .

在有人建议之前,是的,我知道Nifty Assignments,并且已经检查过了 . 只是征求你可能有的任何其他想法 . 我们都记得大学的某些作业特别有趣 . 这些是我理想的经历 .

8 回答

  • 4

    “有趣”作业的麻烦在于,它们往往对学生来说比你想要的更多 . 特别是英语水平较差的学生和最后一分钟完成作业的学生 . [然后用“请做我的作业”问题出现在SO上 . ]他们中的很多人会对你设定的任何作业有困难,但你不需要一群学生抱怨练习的恶化太难了,或者没有在你的讲义中涵盖 .

    我的建议(来自经验)是试图保持背景知识的数量和标记编程任务的“挑战”低 .

    为可选练习设置有趣的问题是一个合理的想法,但重要的是要警告学生不要花费时间在其他更重要的工作上 .

  • 0

    SICP有一些非常好的作业 .

  • 0

    我一直在使用以下页面作为灵感:

    您也可以使用竞赛中的任务(example),但这很可能需要您的一些工作 - 以确保分配任务的公平性(有些可能很棘手,而不是专注于您提到的事情) .

  • 0

    包赋值01; / *确保此类在package assignment01中 . * /

    import java.util.ArrayList; import java.util.Arrays;

    / ** 此类是执行各种数学函数的方法的集合 . 这些方法都是静态的 . 这个类是作业#1的一部分 . * * @author .......... * @version jun 15 2010 * / public class MathLibrary {

    /**
     * Computes and returns the mean (average) of the numbers in the list.
     * 
     * If the input list is empty, the returned mean is 0.0. If the list contains illegal values, the behavior of this
     * method is undefined.
     * 
     * @param list
     *            an ArrayList of double values
     * @return the mean of the values in the list
     */
    public static double mean (ArrayList<Double> list)
    {
        // Variables
    
        Double sum = 0.0;
        int arraySize = 0;
    
        // Check for empty list
    
        if ( list.size()== 0 )
            return 0.0;
    
        // Take sum
    
        arraySize = list.size();
        for( int i = 0; i < arraySize; i++ )
        {
    
            // Check for null Double
    
            if( list.get(i) == null )
            {
                System.out.println("Mean Function: Array has null element at index: " + i + ".");
                return -1.0;
            }
    
            // Add element
    
            sum += list.get(i);
        }
    
        // Return average of results
    
        return (sum / arraySize);
      }
    
    /**
     * Computes and returns the median value of the numbers in the list. If the list has an odd number of elements, the
     * exact median value is returned. If the list has an even number of elements, the average of the middle two
     * elements is returned.
     * 
     * If the input list is empty, the returned mean is 0.0. If the list contains illegal values, the behavior of this
     * method is undefined.
     * 
     * The order of the elements in the input array may be changed by this method.
     * 
     * @param arr
     *            an array of double values
     * @return the median of the values in the list
     */
    public static double median (double[] arr)
    {
         // Variables
    
        double arraySize = 0;
        double arrayMedian = 0.0;
        double temp = 0.0;
        boolean unsorted = true;
    
        // Check for empty array
    
        arraySize = arr.length;
        if (arraySize == 0.0)
            return 0.0;
    
        // Sort array
    
        while(unsorted)
        {
            unsorted = false;
            for( int i=0; i < arraySize - 1; i++)
            {
                if( arr[i] > arr[i+1] )
                {
                    unsorted = true;
                    temp = arr[i + 1];
                    arr[i+1] = arr[i];
                    arr[i] = temp;
                }
            }
        }
    
        // Find median
    
        if((arraySize % 2) == 0) 
        {
            // Take average of two middle array indicies 
    
            arrayMedian = (arr[(int) (arraySize/2.0 - 0.5)] + arr[(int) (arraySize/2.0 + 0.5)]) / 2.0;
        } else {
            arrayMedian = arr[(int) (arraySize/2.0)];
        }
    
    
        return arrayMedian;
      }
    
    /**
     * Computes and returns the largest integer that divides (without remainder) both of the input integers (the
     * greatest common divisor).
     * 
     * If either of the input integers is not positive, this method returns -1.
     * 
     * @param a
     *            any positive integer
     * @param b
     *            any positive integer
     * @return the greatest common divisor of a and b
     */
    public static int gcd (int a, int b)
    {
      int gcd = 1;
      int minimum;
    
      // Check for (a || b) < 0
    
      if ((a < 0) || (b < 0))
          return -1;
      if ((a == 0) || (b == 0))
          return 0;
    
      // Compute half the minimum(a,b)
    
      minimum = Math.min(a,b);
    
      // For each number below half the minimum of the two check for divisibility
    
      for( int i = 1; i <= minimum; i++ ) // zero case is already accounted for
      {
          // Check for divisibility
    
          if(((a % i) == 0) && ((b % i) == 0))
          {
             gcd = i; 
          }
      }
    
         return gcd;
     }
    
    /**
     * Computes and returns the smallest integer that can be divided by (without remainder) both of the input integers
     * (the least common multiple).
     * 
     * 
     * If either of the input integers is not positive, this method returns -1. If the least common multiple exceeds the
     * maximum possible integer value, the behavior of this method is undefined.
     * 
     * @param a
     *            any positive integer
     * @param b
     *            any positive integer
     * @return the least common multiple of a and b
     */
    public static int lcm (int a, int b)
    {
        // Variables
    
        int lcm = 0;
    
        // Check for negative numbers
    
        if((a < 0) || (b < 0))
            return -1;
    
        // Use gcd to get lcm
    
        lcm = (a * b) / gcd(a,b);
    
        return lcm;
      }
    
    /**
     * Given a number n, this method computes and returns the smallest prime number larger than n.
     * 
     * If the input integer is not positive, this method returns 2. If the next prime number exceeds the maximum
     * possible integer value, the behavior of this method is undefined.
     * 
     * @param n
     *            an integer
     * @return the smallest prime number larger than n
     */
    private static boolean isPrime(int n)
    
    {
    
    if( n == 2 || n == 3 )
    {
      return true;
    }
    
    if( n == 1 || n % 2 == 0 )
    {
      return false;
    }
    for( int i = 3; i * i <= n; i += 2 )
    
    if( n % i == 0 )
    {
      return false;
    }
    
    
    return true;
    
    }
    
    public static int nextPrime(int n)
    {
      if (n<0)
    {
      return 2; //if n is not positive.
    }
      int value = n;
      if (n == 2)
       value = 3; //finds the next prime number.
      else
      {
        do
        {
          value += 1;
        } while (!isPrime(value));
      }
      return value; //displays the next prime number.
    }
    

    }

  • 0

    有一点需要考虑,也许不是学生们做的第一个编程课程,而是后来,将他们从以前的作业(他们自己或其他人)的代码交给他们修复 . 如果您选择不正确的提交,这样做会更好,理想情况下会有微妙的缺陷 .

    类似的想法是使用上一个实验室的(成功完成的)代码作为起点, Build 一系列实验 . 当我在LiU进行入门编程课程(PINK - 增量系统编程)时,很多年前,有一段实验室工作(基本上)归结为实现日历,使用抽象类型和访问器,然后之后改变抽象类型的实现 . 非常有 Value ,可以说明需要提供一个好的界面,你不需要一步一步,如果没有其他的东西(从记忆中,我最后花了一两天思考“改变实施”),然后15-20分钟实际改变我的抽象数据类型,因为我已经完成了前面的艰苦工作,只需要说服自己这一点) .

  • 1

    猪拉丁文 .

    让您的学生编写代码,将文本流从英语翻译为Pig Latin . The rules相当简单,但它们需要一些有趣的特殊情况,特别是在标点符号和大小写时,要求它们编写基本的扫描仪/标记器 .

    用这样一个典型的句子:

    Quietly, Anne walked into the forest.
    

    你应该得到这个:

    ietly-quay, Anne-ay alked-way into-ay e-thay orest-fay.
    

    但你可能会得到:

    uietly,-Qay Anne-ay alked-way into-ay e-thay orest.-fay
    

    错误的标点符号,不正确的Qu和不正确的大小写 .

  • 2

    我发现了一些与学 生产环境 生共鸣的想法:

    • 分形艺术 - 一种很好的方式教授递归,因为学生可以想象这个过程(例如sierpinski triangle,L-systems为雄心勃勃的学生) . 您可以在context free art看到使用无上下文语法生成的一些非常令人印象深刻的图形 .

    • 图像处理 - 通过在图像上映射像素操作函数来教授函数编程(例如交换颜色通道,高斯模糊,操纵色调);这比典型的syntax tree-based generative art赋值稍微简单一些 .

    教授入门级计算机科学课程最困难的部分是典型课程中编程能力的差异 . 因此,如果您可以为能力较差的学生创建足够简单的作业,并为高级学生轻松扩展(例如通过额外学分)更复杂的问题,那么这在我看来是理想的 .

  • 1

    当我回想起我在大学的早期阶段时,我非常怀念的一项任务是一项旨在教我们GUI的任务 . 我们被要求实施网络浏览器 .

    Web内容的实际显示并不是特别重要 - 我们鼓励使用Swing Web视图 - 它更多地是关于支持此功能的功能:

    • 一个URL栏

    • 历史

    • 前进和后退

    • 设置主页

    • 维护书签/收藏夹

    • 标签式浏览

    如果您至少设定了一组编号,则该任务可让您自由选择这些组合 . 这使得真正敏锐的人们可以根据需要实现绝对的所有功能,并允许任何更急于实现最低限度的人 .

    多年来还有一些以类似方式构建的任务,它们总是很顺利 . 你会惊讶地发现,学生们往往会付出额外的努力并且做得超过要求 .


    作为一般的经验法则,我和我的同伴似乎发现最具吸引力的东西更具视觉效果:OpenGL,GUI,网站等 . 任何基于命令行的程序都不那么有趣 .

    也许当你专注于算法时,让学生可视化排序/搜索算法可能是一个好主意 . 除了向他们讲述图形框架之外,它还有助于可视化算法并巩固他们对算法的理解 . 您可以使用数据结构的自定义实现执行类似的操作 .

    关键是找到一个相当直观,文档齐全,使用良好且支持良好的图形框架 . 没有什么比强制我们使用现实世界中没有人真正使用的技术的任务更令人沮丧的了 . 您不希望将学习此技术作为任务中最难的部分 .

    我不认为你教他们使用可能被认为超出模块范围的框架是一件坏事:学习如何使用新的框架和库本身就是一项需要开发的技能如果你是一个有效的软件开发人员,大学似乎没有明确地教导这一点 .

相关问题