PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Kickoff

Generate boolean truth table

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of parsing, boolean expression semantics, and algorithmic enumeration, including tokenization, operator precedence, exhaustive evaluation over variable assignments, and handling of invalid inputs.

  • Medium
  • Kickoff
  • Coding & Algorithms
  • Software Engineer

Generate boolean truth table

Company: Kickoff

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Implement a function that, given a string boolean expression, outputs a complete truth table. The expression syntax is: variables are single uppercase letters A–Z; operators are '!' (unary NOT), adjacency (implicit AND), and '+' (binary OR); parentheses '()' are allowed; spaces are ignored. Use precedence: '!' > AND > '+', with left-associative AND and OR. Requirements: ( 1) Parse the expression (handle implicit AND) and validate tokens; ( 2) Extract all distinct variables, sort them alphabetically; ( 3) Enumerate all 2^n assignments and evaluate the expression for each; ( 4) Print rows as variable values followed by the expression’s result. Example: input "!AB + B!D + !(CD)" should produce a table over A,B,C,D with all 16 combinations. Describe your parsing approach (e.g., shunting-yard or recursive descent), data structures used, and analyze time/space complexity. Discuss edge cases such as unmatched parentheses, unknown symbols, or empty input.

Quick Answer: This question evaluates understanding of parsing, boolean expression semantics, and algorithmic enumeration, including tokenization, operator precedence, exhaustive evaluation over variable assignments, and handling of invalid inputs.

Kickoff logo
Kickoff
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

Implement a function that, given a string boolean expression, outputs a complete truth table. The expression syntax is: variables are single uppercase letters A–Z; operators are '!' (unary NOT), adjacency (implicit AND), and '+' (binary OR); parentheses '()' are allowed; spaces are ignored. Use precedence: '!' > AND > '+', with left-associative AND and OR. Requirements: (

  1. Parse the expression (handle implicit AND) and validate tokens; (
  2. Extract all distinct variables, sort them alphabetically; (
  3. Enumerate all 2^n assignments and evaluate the expression for each; (
  4. Print rows as variable values followed by the expression’s result. Example: input "!AB + B!D + !(CD)" should produce a table over A,B,C,D with all 16 combinations. Describe your parsing approach (e.g., shunting-yard or recursive descent), data structures used, and analyze time/space complexity. Discuss edge cases such as unmatched parentheses, unknown symbols, or empty input.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Kickoff•More Software Engineer•Kickoff Software Engineer•Kickoff Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.