Recent content by Enharmonics

  1. E

    Calculations using Standard Deviation and Mean

    Homework Statement Homework Equations Chebyshev's Theorem: The percentage of observations that are within k standard deviations of the mean is at least 100(1 - (1/k2))% Chebyshev's Theorem is applicable to ANY data set, whether skewed or symmetrical. Empirical Rule: For a symmetrical...
  2. E

    Proof by Induction of shortest suffix of concatenated string

    Homework Statement Wherein α, β are strings, λ = ∅ = empty string, βr is the shortest suffix of the string β, βl is the longest prefix of the string β, and T* is the set of all strings in the Alphabet T, |α| denotes the length of a string α, and the operator ⋅ (dot) denotes concatenation of...
  3. E

    Proof by Induction of String exponentiation? (Algorithms)

    Thanks! I must've mixed up the order of the steps while desperately trying to figure this out yesterday. I've revised my inductive step to reflect that fact. Here's the new version: LHS = |αn| = |αk + 1| = |(αk) ⋅ α| = |αk| + |α| = k|α| + |α| = (k+1)|α| = n|α| = RHS Is this better? Also, is...
  4. E

    Proof by Induction of String exponentiation? (Algorithms)

    After a few hours of trying, I managed to make it through the synthetic method using induction on n and another proposition (I'll call it "Length of Concatenated Strings", that was proven in class: So here's the base case: I'll pause here to note that I'm not confident this is right; in...
  5. E

    Proof by Induction of String exponentiation? (Algorithms)

    Homework Statement Wherein α is a string, λ = ∅ = the empty string, and T* is the set of all strings in the Alphabet T. Homework Equations (exp-Recursive-Clause 1) : α0 = λ (exp-Recursive-Clause 2) : αn+1 = (αn) ⋅ α The Attempt at a Solution [/B] This one is proving difficult for me. I...
  6. E

    Implementing a Unix Shell in C

    Homework Statement Assignment instructions are as follows: For the purposes of this assignment, we've been provided with some skeleton code (the "myshell.c" program mentioned in the instructions). I'll post it here: #include <stdio.h> #include <sys/wait.h> #include <unistd.h> #include...
  7. E

    C - getting filenames from stdin/stdout for use in getopt

    So I was reading through the implementation of the read/write methods given by my professor to see if maybe there was a clue there that could help me figure out how to do this. Here's the code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <string.h>...
  8. E

    C - getting filenames from stdin/stdout for use in getopt

    Homework Statement The assignment I'm doing involves manipulating an image stored in a 24-bit uncompressed BMP file. We were provided with two pre-written files (a header and a .c source file) that contain functions that read and write the image file, as well as a flip() function (mirrors the...
  9. E

    Tricky Segmentation Fault in C

    I suspected as much! I changed the line strcpy(fileDirectory, argv[optind] to if (argv[optind] != NULL) { strcpy(fileDirectory, argv[optind] } That fixed everything right up. Knowing that argv[optind] is NULL in cases like this will come in handy in the future. Thanks!
  10. E

    Tricky Segmentation Fault in C

    I put some thought into this. Checking a few different documentation sources for the getopt() function, I eventually found something that looked interesting: https://linux.die.net/man/3/optind So if filename doesn't exist, optind would point to the first argv element that isn't an option...
  11. E

    Tricky Segmentation Fault in C

    Homework Statement Write a C program to run on ocelot to find the total count of words and optionally the longest and or shortest words in a string input by the user or coming from a file. If there is no filename the user would be prompted to enter the string. You must use getopt to parse the...
  12. E

    Trouble with Extended Multiplication in LC-3 Assembly

    Homework Statement So basically, I have to implement the algorithm given in the relevant equations section. Homework Equations The Attempt at a Solution First and foremost, my code. Some bits that weren't directly relevant to the problem I'm having were removed for readability's sake...
  13. E

    Moving LC-3 P.C. more than 256 Hex addresses down? [Binary]

    You're absolutely right, but since the LC-3 sign-extends its 9-bit PC-offset values to 16 bits, using (for example) 1 1111 1111 as the offset would actually yield b1111 1111 1111 1111 = xFFFF Rather than b0000 0001 1111 1111 = x01FF = d511. That's why I couldn't use b0000 01000 1000 1101 =...
  14. E

    Moving LC-3 P.C. more than 256 Hex addresses down? [Binary]

    Homework Statement I'm writing a program in binary on the LC-3. The program counts the occurrences of a specific character in a file. Relevant excerpts from the assignment instructions: 1) Download the source code for Figure 5.17 from the textbook webpage as code1.bin. Code x3000 as the...
  15. E

    Comp Sci Implementing a PriorityQueue w/ a Doubly-Linked List (Java)

    You're absolutely right. Thanks so much for pointing that out. I hadn't realized that I had been overwriting firstLink and lastLink repeatedly rather than actually inserting "between" them by using their next and previous pointers. As soon as I sorted that out, things got better. That's what I...
Back
Top