Forums - Open Redstone Engineers
most common interview questions! - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: Off-Topic (https://forum.openredstone.org/forum-4.html)
+--- Forum: Programming (https://forum.openredstone.org/forum-8.html)
+--- Thread: most common interview questions! (/thread-6123.html)

Pages: 1 2


most common interview questions! - VoltzLive - 04-08-2015

I've been looking around the internet and I believe I have found the five most common programmer interview questions.
I want to see your solutions.

  1.  fizzbuzz
  2.  matrix multiplication
  3.  prime factorization
  4.  huffman compression
  5.  fast fourier transform



RE: most common interview questions! - LordDecapo - 04-09-2015

#IdGoogleIt


RE: most common interview questions! - Xray_Doc - 04-09-2015

Also combinatoral explosion


RE: most common interview questions! - Tommyand - 04-18-2015

Code:
void FizzBuzz(int x) {
 if (x % 3 == 0) // Or (!(x % 3))
   printf("Fizz");
 if (x % 5 == 0) // Or (!(x % 5))
   printf("Buzz");
 printf("\n");
 return;
}

int main(void) {
 for (int x=0;x=x+1;x<=10)
   FizzBuzz(x);
 return 0;
}
FizzBuzz in C, as close as I remember. My C-fu is weak...
I'm taking it into another function, because grouping, and leaving out most unnecessary syntax, while keeping the returns. If I wanted to make it small, i'd inline it, use the alternative boolean if statement, and abuse argc.
I forget: does C now include constructs like x++; or ++x; ? I know they're in C++...


RE: most common interview questions! - greatgamer34 - 04-19-2015

prime factorization

PHP Code:
//Asks the user for a number, then computes the prime factorization of it.
//Jarvis, Alex J.
//3/25/15
//Language c++ / g++ target

#include <iostream>

using namespace std;
#include "Stack.h"  //Header file for stack functions


int main(void)
{
Stack prime      //Create an instance of stack "prime"
int inputi;
cout<<"Enter an integer to be prime factored: ";
cin>>input;
cout<<endl;

for (
int i=2<= inputi++)
 {
 
 while(input == 0)
 
     {
    
input /= i
    
prime.push(i);
 
     
 }
prime.display(cout); //Prints the factors out
 
  return 0;




RE: most common interview questions! - GISED_Link - 04-20-2015

(04-18-2015, 07:59 AM)Tommyand Wrote:
Code:
#include <stdio.h>

void FizzBuzz(int x);    //Header of the function

int main(void) {
    int x;                 //cannot declare a variable in the condition of the loop (valid in C++, java but not i C(95 ?)
    for (x=1; x<=10 ;x++){
        FizzBuzz(x);
    }
    return 0;
}

void FizzBuzz(int x) {                //the function
    if (x % 3 == 0){ // Or (!(x % 3))
        printf("%d : Fizz\n", x);
    }
    if (x % 5 == 0){ // Or (!(x % 5))
        printf("%d : Buzz\n", x);
    }
}

I correct it... It miss a lot of {} (after the if and the for), I show x when fizz or buzz is found and add the stdio library


RE: most common interview questions! - tyler569 - 04-20-2015

Great: that indentation XD

my eyes are bleeding.


RE: most common interview questions! - greatgamer34 - 04-21-2015

Isnt it so great?? :3


RE: most common interview questions! - Tommyand - 04-27-2015

(04-20-2015, 08:21 AM)GISED_Link Wrote:
(04-18-2015, 07:59 AM)Tommyand Wrote:
Code:
#include <stdio.h>

void FizzBuzz(int x);    //Header of the function

int main(void) {
    int x;                 //cannot declare a variable in the condition of the loop (valid in C++, java but not i C(95 ?)
    for (x=1; x<=10 ;x++){
        FizzBuzz(x);
    }
    return 0;
}

void FizzBuzz(int x) {                //the function
    if (x % 3 == 0){ // Or (!(x % 3))
        printf("%d : Fizz\n", x);
    }
    if (x % 5 == 0){ // Or (!(x % 5))
        printf("%d : Buzz\n", x);
    }
}

I correct it... It miss a lot of {} (after the if and the for), I show x when fizz or buzz is found and add the stdio library

I specifically left out the brackets because they are unnecessary, because it's a single line of code inside the if / for, and that is allowed in C. I was thinking about that, and it does look nicer without them...

The initialization of the variable inside the for loop? Like I said, weak C-foo. I did C++, not C.

However, switching around the order of the functions made little sense, and you actually messed up the FizzBuzz function. That final printf('/n') is seperate for a reason... So, my suggustion would be to put the number in the final printf statement, along with the newline. So...
Code:
if (blah)
   printf("Fizz");
if (blah2)
   printf("Buzz");
printf(": %d\n, x);



RE: most common interview questions! - jackpeppin - 09-16-2015

1,Have an interview coming up?
2,“Tell me about yourself.”
3,“What interests you about this job?”
4,“Why are you thinking about leaving your job?” Or: “Why did you leave your last job?”
5,“Why would you excel at this job?”
6,“What do you know about our company so far?”
7,“Tell me about a time when …”
8,“What would you do in your first 90 days in this position?”
9,“What’s most important to you in a new position?”
10,“What salary range are you looking for?”

[SPAM LINK REMOVED]