-  [JOIN IRC!]


[Return]
Posting mode: Reply
Name
Subject   (reply to 348)
Message
File
Password  (for post and file deletion)
¯\(°_O)/¯
  • Supported file types are: BMP, GIF, JPG, PNG
  • Maximum file size allowed is 10000 KB.
  • Images greater than 400x400 pixels will be thumbnailed.
  • Currently 317 unique user posts. View catalog

  • Blotter updated: 2015-09-02 Show/Hide Show All


File 13510126317.jpg - (9.35KB , 220x299 , 220px-The_C_Programming_Language_1st_edition_cover.jpg )
348 No. 348
I have a programming assignment due in 13 hours and I'm a bit stuck on it guys,
We're doing this in C.
Basically we're given a chunk of text, and our job is to compress this. the output contains number pairs that are 'offset, length': the number of characters you have to go back, and the length of the copied string. eg for the phrase 'she sells sea shells he shells and she sells',
the first four characters (including the space) are new, so their offset is 0 and their length is their ASCII code, but the 's' in 'sells' has been seen before, so its offset is 4 (you have to go 4 characters back to find the other s) and length = 1.
The next part is to basically speed up the process by replacing brute force by algorithmic force. Instead of using nested loops and literally comparing each character to every one before it, we have to get smart, and I can't quite do that right now.
If anyone wanted to help me out that would be so fantastic guys! Below is the start of my code, moving the input file into an array:
#include <stdio.h>
#define MAXBYTES 1000000
char input
char text[MAXBYTES]
int textlength = 0;
while(textlength<MAXBYTES&&scanf("%c", &input)==1) {
text[textlength]=input;
textlength++;
}
>> No. 351
> due in 13 hours
stackoverflow.com is your friend, if you have a google account (gmail) you can log-in through that
>> No. 353
I'm kind of confused OP.

So you get a string, and then you're asked to compress it. Compress the string into what exactly?

Do you mean remove redundant words in a string? I don't understand lol.
>> No. 357
read length(i) offset(i)

store length(i) in array{i}

read length (i+1)

store length(i+i) in array{i}

check if length(i+1) is in array

if then offset(i+1) = array{i+1} - array{in which length(i+1)}


I've stumbled upon this thread and shitted it with what came to my mind at 3:29 without any effort. Sorry you have to see this.


Delete post []
Password  
Report post
Reason