The theoretical investigation reported here has two objectives: (i) to compare the values of polarizability-alpha and second hyperpolarizability gamma-obtained by the semiempirical INDO method with those obtained by the ab initio method, both utilizing the derivative approach, and (ii) to study the dependence of the alpha and gamma on the nature of the extended pi-electron structure in a group of compounds such as the six carbon atom molecules hexapentaene, hexadiyne, and divinylacetylene. First, to examine the dispersion and basis set effects, frequency-dependent alpha and different gamma-terms, responsible for various third-order nonlinear optical effects, are calculated for hexadiyne by the ab initio time-dependent Hartree-Fock method employing both STO-3G and 4-31G basis sets, the latter augmented with p and d semidiffuse functions on carbon. The coupled perturbed Hartree-Fock analytical method is used to compute the various derivatives. Compared to the extended basis results the minimal basis set, STO-3G, is found to heavily underestimate the values of alpha and gamma. The zero-frequency limit static-alpha and gamma-values for hexapentaene, hexadiyne, and divinylacetylene are calculated by the ab initio method using STO-3G and an augmented 6-31G basis set. The INDO method is used with the traditionally used minimal basis set involving a single zeta-function to calculate the alpha and gamma values. The required derivatives for this calculation are obtained by the numerical finite field method. For each molecule, the INDO method gives the alpha and gamma values which are significantly lower than those obtained with the extended basis set, augmented 6-31G, but comparable to the results obtained with the minimal basis set, STO-3G, in the ab initio calculation. In the group of six-carbon straight-chain molecules, alpha-shows an increasing trend with the number of pi-electrons but no definite trend is observed for the gamma values.